fix(tui): make single-line paste atomic to avoid @ autocomplete lag

closes #1812
This commit is contained in:
Mario Zechner 2026-03-04 18:25:37 +01:00
parent 49749407fa
commit 689e7b4ac2
3 changed files with 23 additions and 4 deletions

View file

@ -6,6 +6,7 @@
- Fixed TUI width calculation for regional indicator symbols (e.g. partial flag sequences like `🇨` during streaming) to prevent wrap drift and stale character artifacts in differential rendering.
- Fixed Kitty CSI-u handling to ignore unsupported modifiers so modifier-only events do not insert stray printable characters ([#1807](https://github.com/badlogic/pi-mono/issues/1807))
- Fixed single-line paste performance by inserting pasted text atomically instead of character-by-character, preventing repeated `@` autocomplete scans during paste ([#1812](https://github.com/badlogic/pi-mono/issues/1812))
## [0.55.4] - 2026-03-02

View file

@ -1029,10 +1029,8 @@ export class Editor implements Component, Focusable {
}
if (pastedLines.length === 1) {
// Single line - insert character by character to trigger autocomplete
for (const char of filteredText) {
this.insertCharacter(char, true);
}
// Single line - insert atomically (do not trigger autocomplete during paste)
this.insertTextAtCursorInternal(filteredText);
return;
}

View file

@ -1496,6 +1496,26 @@ describe("Editor component", () => {
assert.strictEqual(editor.getText(), "hello| world");
});
it("does not trigger autocomplete during single-line paste", () => {
const editor = new Editor(createTestTUI(), defaultEditorTheme);
let suggestionCalls = 0;
const mockProvider: AutocompleteProvider = {
getSuggestions: () => {
suggestionCalls += 1;
return null;
},
applyCompletion,
};
editor.setAutocompleteProvider(mockProvider);
editor.handleInput("\x1b[200~look at @node_modules/react/index.js please\x1b[201~");
assert.strictEqual(editor.getText(), "look at @node_modules/react/index.js please");
assert.strictEqual(suggestionCalls, 0);
assert.strictEqual(editor.isShowingAutocomplete(), false);
});
it("undoes multi-line paste atomically", () => {
const editor = new Editor(createTestTUI(), defaultEditorTheme);