mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 09:09:08 +00:00
On Autocomplete insertion, set cursor carat inside () if method has parameters
This commit is contained in:
1 parent
6f1fc08a08
commit
720d0dc1b9
2 files changed
+18
No files matched your search
@@ -523,6 +523,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
return selection.getCursorPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCursorPosition(int position) {
|
||||
selection.reset(Math.max(0, Math.min(position, GuiScriptTextArea.this.text.length())));
|
||||
scrollToCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return GuiScriptTextArea.this.text;
|
||||
|
||||
+12
@@ -91,6 +91,12 @@ public class AutocompleteManager {
|
||||
*/
|
||||
int getCursorPosition();
|
||||
|
||||
/**
|
||||
* Set cursor position.
|
||||
* @param position New cursor position
|
||||
*/
|
||||
void setCursorPosition(int position);
|
||||
|
||||
/**
|
||||
* Get current document text.
|
||||
*/
|
||||
@@ -543,6 +549,12 @@ public class AutocompleteManager {
|
||||
// This prevents position corruption since import adds text at the TOP
|
||||
insertCallback.replaceTextRange(insertText, prefixStartPosition, endPos);
|
||||
|
||||
// If the inserted text ends with (), move cursor inside only when parameters exist
|
||||
if (insertText.endsWith("()") && item.getParameterCount() > 0) {
|
||||
int currentCursor = insertCallback.getCursorPosition();
|
||||
insertCallback.setCursorPosition(currentCursor - 1);
|
||||
}
|
||||
|
||||
// If this item requires an import, add it AFTER the text replacement
|
||||
if (item.requiresImport() && item.getImportPath() != null) {
|
||||
insertCallback.addImport(item.getImportPath());
|
||||
|
||||
Reference in new issue
Block a user