mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 04:09:57 +00:00
Improved comment/string excluded range detection for auto-pair insertion
This commit is contained in:
1 parent
ea8cc51eef
commit
235fd3b3f3
2 files changed
+13
-2
No files matched your search
@@ -2375,7 +2375,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
// Auto-pair insertion: when opening a quote/brace/bracket is typed,
|
||||
// insert a matching closer and place caret between the pair.
|
||||
// But only if the current position is not excluded (e.g., inside a comment or string)
|
||||
if (!container.getDocument().isExcluded(cursorPos)) {
|
||||
if (!container.getDocument().isExcludedInclusive(cursorPos)) {
|
||||
if (c == '"') {
|
||||
setText(before + "\"\"" + after, true);
|
||||
selection.reset(before.length() + 1);
|
||||
|
||||
@@ -444,6 +444,17 @@ public class ScriptDocument {
|
||||
|
||||
|
||||
public boolean isExcluded(int position) {
|
||||
for (int[] range : excludedRanges) {
|
||||
if (position >= range[0] && position < range[1]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Inclusive version for precision with end offset
|
||||
Check GuiScriptTextArea#handleCharacterInput */
|
||||
public boolean isExcludedInclusive(int position) {
|
||||
for (int[] range : excludedRanges) {
|
||||
if (position >= range[0] && position <= range[1]) {
|
||||
return true;
|
||||
@@ -4739,7 +4750,7 @@ public class ScriptDocument {
|
||||
/**
|
||||
* Mark chained field accesses like: mc.player.world, array.length, this.field, etc.
|
||||
* This handles dot-separated access chains and colors each segment appropriately.
|
||||
* Does NOT mark method calls (identifiers followed by parentheses) - those are handled by markMethodCalls.
|
||||
* Does NOT mark method calls (identifiers followed by parentheses) - those are handled by {@link #markMethodCalls}.
|
||||
*/
|
||||
private void markChainedFieldAccesses(List<ScriptLine.Mark> marks) {
|
||||
FieldChainMarker marker = new FieldChainMarker(this, text);
|
||||
|
||||
Reference in new issue
Block a user