fix(tui): stop chaining slash arg autocomplete after Tab closes #2577

This commit is contained in:
Mario Zechner
2026-03-24 23:52:48 +01:00
parent ebe437081e
commit 21950c5ba4
2 changed files with 1 additions and 26 deletions

View File

@@ -9,6 +9,7 @@
### Fixed
- Fixed blockquote text color breaking after inline links (and other inline elements) due to missing style restoration prefix
- Fixed slash-command Tab completion from immediately chaining into argument autocomplete after completing the command name, restoring flows like `/model` that submit into a selector dialog ([#2577](https://github.com/badlogic/pi-mono/issues/2577))
## [0.62.0] - 2026-03-23

View File

@@ -591,8 +591,6 @@ export class Editor implements Component, Focusable {
if (kb.matches(data, "tui.input.tab")) {
const selected = this.autocompleteList.getSelectedItem();
if (selected && this.autocompleteProvider) {
const shouldChainSlashArgumentAutocomplete = this.shouldChainSlashArgumentAutocompleteOnTabSelection();
this.pushUndoSnapshot();
this.lastAction = null;
const result = this.autocompleteProvider.applyCompletion(
@@ -607,10 +605,6 @@ export class Editor implements Component, Focusable {
this.setCursorCol(result.cursorCol);
this.cancelAutocomplete();
if (this.onChange) this.onChange(this.getText());
if (shouldChainSlashArgumentAutocomplete && this.isBareCompletedSlashCommandAtCursor()) {
this.tryTriggerAutocomplete();
}
}
return;
}
@@ -1986,26 +1980,6 @@ export class Editor implements Component, Focusable {
return this.isSlashMenuAllowed() && textBeforeCursor.trimStart().startsWith("/");
}
private shouldChainSlashArgumentAutocompleteOnTabSelection(): boolean {
if (this.autocompleteState !== "regular") {
return false;
}
const currentLine = this.state.lines[this.state.cursorLine] || "";
const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
return this.isInSlashCommandContext(textBeforeCursor) && !textBeforeCursor.trimStart().includes(" ");
}
private isBareCompletedSlashCommandAtCursor(): boolean {
const currentLine = this.state.lines[this.state.cursorLine] || "";
if (this.state.cursorCol !== currentLine.length) {
return false;
}
const textBeforeCursor = currentLine.slice(0, this.state.cursorCol).trimStart();
return /^\/\S+ $/.test(textBeforeCursor);
}
// Autocomplete methods
/**
* Find the best autocomplete item index for the given prefix.