Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai a9714d98ca fix(completion): complete a keyword rather than a declaration snippet of the same name
jdtls lists both the keyword `interface` and a snippet `interface` that inserts a whole
declaration named after the file. Picking the snippet while changing `class` to
`interface` duplicated the declaration. A server snippet whose label matches a keyword the
same list offers is dropped, as IDEA completes only the keyword.

Fixes #7151
2026-12-01 15:38:44 +08:00
2 змінених файлів з 39 додано та 0 видалено

No files matched your search

+35
Переглянути файл
@@ -540,6 +540,41 @@ describe("applying completions", () => {
expect(a!.apply).not.toBe(b!.apply);
});
it("completes a keyword rather than a declaration snippet with the same name", async () => {
const { view } = setup("public interf| Demo {}");
setInvokeRoute((cmd) => {
if (cmd === "cancel_request") return Promise.resolve(null);
if (cmd === "lsp_completion") {
return Promise.resolve({
isIncomplete: false,
items: [
item({ label: "interface", kind: "keyword", insertText: "interface" }),
item({
label: "interface",
kind: "snippet",
insertText: "public interface ${1:Demo} {\n\t$0\n}",
isSnippet: true,
}),
],
});
}
return Promise.resolve(null);
});
try {
view.dispatch({
effects: StateEffect.appendConfig.of([
lspDoc.of({ doc: 7151, path: "/p/Demo.java", language: "java", uiMode: "Java", readOnly: false }),
completionExtension(),
]),
});
startCompletion(view);
await vi.waitFor(() => expect(currentCompletions(view.state)).toHaveLength(1));
expect((currentCompletions(view.state)[0] as unknown as { lsp: CompletionItem }).lsp.kind).toBe("keyword");
} finally {
setInvokeRoute(null);
}
});
it("lists same-name Java imports from different packages", async () => {
const { view } = setup("@RequestBod|");
const packages = ["org.springframework.web.bind.annotation", "io.swagger.v3.oas.annotations.parameters"];
+4
Переглянути файл
@@ -875,6 +875,10 @@ async function lspCompletionSource(ctx: CompletionContext): Promise<CompletionRe
if (inVarCall(ctx)) items = items.filter((it) => !it.label.startsWith("--"));
const pruned = pruneItems(items, typed);
items = [...pruned.items];
// A server snippet named like a keyword it also lists (jdtls `interface`, `class`, `enum` declaration
// skeletons) would replace one word with a whole declaration; IDEA completes the keyword.
const keywords = new Set(items.filter((it) => it.kind === "keyword").map((it) => it.label));
if (keywords.size) items = items.filter((it) => it.kind !== "snippet" || !keywords.has(it.label));
// A server snippet named like a live template (jdtls `sout`, `fori`) would be listed twice; the template wins.
if (items.some((it) => it.kind === "snippet")) {
const own = await contributedSource(ctx);