From 5026a5b7f5d4f38e2be6edfcaf334b5dfd303522 Mon Sep 17 00:00:00 2001 From: Venya Sharma Date: Tue, 21 Jul 2026 10:57:06 -0500 Subject: [PATCH] Add provideCompletionItem middleware to rewrite MP snippet filterText MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VS Code's fuzzyScore requires matched characters to start at a word boundary (uppercase letter, space, start of string). The MP language server sets both label and filterText to lowercase tokens like 'mpliveness' with no boundaries, so partial word matches like 'live' or 'health' score 0 and the item never surfaces. Rewrite filterText to the item's human-readable detail string ('MicroProfile Health liveness check') before items are returned to VS Code. This gives the fuzzy engine real word boundaries to match against, so queries like 'live', 'health', 'readi', 'check' all work. Note: pure mid-word subsequences like 'ven' (no boundary before 'v' in 'liveness') are not achievable with VS Code's boundary-anchored fuzzyScore regardless of filterText value — this is a known engine limitation compared to LSP4E's ordered subsequence matching and LSP4IJ's dual lookup string registration. This mirrors: - LSP4IJ: getAllLookupStrings() registers both filterText and label - LSP4E: CompletionProposalTools ordered subsequence matching Fixes: https://github.com/OpenLiberty/liberty-tools-vscode/issues/341 --- src/extension.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 2a1b290..717f6f5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -270,6 +270,22 @@ async function connectToLS(context: ExtensionContext, api: JavaExtensionAPI, doc hover.contents = newContents; return hover; }, + provideCompletionItem: async (document, position, context, token, next): Promise => { + const result = await next(document, position, context, token); + const items: VSCompletionItem[] = Array.isArray(result) ? result : (result?.items ?? []); + for (const item of items) { + // Rewrite filterText to item.detail (e.g. "MicroProfile Health liveness check") + // so VS Code's fuzzyScore has real word boundaries to match against. + // Both label and filterText are the short lowercase token ("mpliveness") — detail + // carries the human-readable description that gives fuzzy matching real boundaries. + // This mirrors what LSP4IJ achieves via getAllLookupStrings() and what LSP4E + // achieves via ordered subsequence matching on filterText. + if (item.filterText && item.detail && item.filterText !== item.detail) { + item.filterText = item.detail; + } + } + return result; + }, resolveCompletionItem: async (item, token, next): Promise => { const completionItem = await next(item, token); if (completionItem !== undefined && completionItem !== null && completionItem.documentation instanceof MarkdownString) {