feat(coding-agent,tui): add stacked autocomplete providers closes #2983
This commit is contained in:
@@ -2132,6 +2132,39 @@ describe("Editor component", () => {
|
||||
assert.strictEqual(editor.isShowingAutocomplete(), true);
|
||||
});
|
||||
|
||||
it("debounces # autocomplete while typing", async () => {
|
||||
const editor = new Editor(createTestTUI(), defaultEditorTheme);
|
||||
let suggestionCalls = 0;
|
||||
|
||||
const mockProvider: AutocompleteProvider = {
|
||||
getSuggestions: async (lines, _cursorLine, cursorCol) => {
|
||||
suggestionCalls += 1;
|
||||
const text = (lines[0] || "").slice(0, cursorCol);
|
||||
return {
|
||||
items: [{ value: "#2983", label: "#2983" }],
|
||||
prefix: text,
|
||||
};
|
||||
},
|
||||
applyCompletion,
|
||||
};
|
||||
|
||||
editor.setAutocompleteProvider(mockProvider);
|
||||
|
||||
editor.handleInput("#");
|
||||
editor.handleInput("2");
|
||||
editor.handleInput("9");
|
||||
editor.handleInput("8");
|
||||
|
||||
assert.strictEqual(suggestionCalls, 0);
|
||||
assert.strictEqual(editor.isShowingAutocomplete(), false);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
await flushAutocomplete();
|
||||
|
||||
assert.strictEqual(suggestionCalls, 1);
|
||||
assert.strictEqual(editor.isShowingAutocomplete(), true);
|
||||
});
|
||||
|
||||
it("aborts active @ autocomplete when typing continues", async () => {
|
||||
const editor = new Editor(createTestTUI(), defaultEditorTheme);
|
||||
let aborts = 0;
|
||||
|
||||
Reference in New Issue
Block a user