Fix slash command autocomplete Enter behavior
When pressing Enter on a highlighted slash command suggestion (e.g., typing `/mod` with `/model` highlighted), the completion is now applied before submitting. Previously, the partial text was submitted instead of the selected command. Fixes #49
This commit is contained in:
@@ -220,8 +220,22 @@ export class Editor implements Component {
|
||||
return;
|
||||
}
|
||||
|
||||
// If Enter was pressed on a slash command, cancel autocomplete and let it submit
|
||||
// If Enter was pressed on a slash command, apply completion and submit
|
||||
if (data === "\r" && this.autocompletePrefix.startsWith("/")) {
|
||||
const selected = this.autocompleteList.getSelectedItem();
|
||||
if (selected && this.autocompleteProvider) {
|
||||
const result = this.autocompleteProvider.applyCompletion(
|
||||
this.state.lines,
|
||||
this.state.cursorLine,
|
||||
this.state.cursorCol,
|
||||
selected,
|
||||
this.autocompletePrefix,
|
||||
);
|
||||
|
||||
this.state.lines = result.lines;
|
||||
this.state.cursorLine = result.cursorLine;
|
||||
this.state.cursorCol = result.cursorCol;
|
||||
}
|
||||
this.cancelAutocomplete();
|
||||
// Don't return - fall through to submission logic
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user