mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-12 09:24:24 +00:00
* fix(terminal): raise autocomplete suggestion default beyond 8 Snippet keyword matches were truncated at autocompleteMaxSuggestions=8 before the floating list, so users with many matching scripts could not scroll to the rest (fixes #2793). Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): migrate persisted autocompleteMaxSuggestions 8 to 50 Existing installs saved the old default into localStorage with no settings UI, so raising DEFAULT alone left the popup capped at 8. Treat 8 as the legacy sentinel while preserving intentional custom caps. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { getCompletions } from "./autocomplete/completionEngine";
|
|
import { DEFAULT_AUTOCOMPLETE_SETTINGS } from "./autocomplete/useTerminalAutocomplete";
|
|
import type { Snippet } from "../../domain/models";
|
|
|
|
const deploySnippet: Snippet = { id: "d", label: "deploy", command: "kubectl apply -f ." };
|
|
|
|
test("getCompletions includes snippet suggestions at the command position", async () => {
|
|
const out = await getCompletions("dep", { snippets: [deploySnippet] });
|
|
const snip = out.find((s) => s.source === "snippet");
|
|
assert.ok(snip, "expected a snippet suggestion");
|
|
assert.equal(snip?.displayText, "deploy");
|
|
});
|
|
|
|
test("getCompletions does not surface snippets past the command position", async () => {
|
|
const out = await getCompletions("git dep", { snippets: [deploySnippet] });
|
|
assert.equal(out.find((s) => s.source === "snippet"), undefined);
|
|
});
|
|
|
|
test("getCompletions returns more than 8 snippet matches when default maxSuggestions allows it", async () => {
|
|
const snippets: Snippet[] = Array.from({ length: 20 }, (_, i) => ({
|
|
id: `s${i}`,
|
|
label: `deploy-${String(i).padStart(2, "0")}`,
|
|
command: `echo deploy-${i}`,
|
|
}));
|
|
|
|
assert.ok(
|
|
DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions > 8,
|
|
`expected raised default maxSuggestions (>8), got ${DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions}`,
|
|
);
|
|
|
|
const out = await getCompletions("dep", {
|
|
snippets,
|
|
maxResults: DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions,
|
|
});
|
|
const snippetMatches = out.filter((s) => s.source === "snippet");
|
|
assert.ok(
|
|
snippetMatches.length > 8,
|
|
`expected more than 8 snippet matches for scrolling popup, got ${snippetMatches.length}`,
|
|
);
|
|
assert.equal(snippetMatches.length, 20);
|
|
});
|