Add provideCompletionItem middleware to rewrite MP snippet filterText - #610
Open
sharma1208 wants to merge 1 commit into
Open
Add provideCompletionItem middleware to rewrite MP snippet filterText#610sharma1208 wants to merge 1 commit into
sharma1208 wants to merge 1 commit into
Conversation
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: OpenLiberty/liberty-tools-vscode#341
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MicroProfile snippet completion items (
mpliveness,mpreadiness,mpnrc) only surface in VS Code when the user types the exact prefixmp. Typing a meaningful word fragment likelive,health, orreadireturns nothing.The MP language server sets both
labelandfilterTextto the same short lowercase token (e.g."mpliveness"). VS Code'sfuzzyScorerequires matched characters to start at a word boundary like an uppercase letter, space, or start of string. A string like"mpliveness"has no boundaries, so only a prefix matches.This works fine in IntelliJ (LSP4IJ registers both
filterTextandlabelas lookup strings) and Eclipse (LSP4E uses ordered subsequence matching), but VS Code has no equivalent layer.Fix
Add a
provideCompletionItemmiddleware hook that rewritesfilterTextfrom the opaque token toitem.detail(e.g."mpliveness"→"MicroProfile Health liveness check") before items are returned to VS Code. This gives the fuzzy engine real word boundaries to match against.The rewrite is guarded so it only applies when
filterTextanddetailexist and differ, so regular Java completions are unaffected.What works after this fix
mplivereadihealthcheckKnown limitation
Pure mid-word subsequences like
ven(no word boundary beforevinliveness) are not achievable with VS Code's boundary-anchoredfuzzyScoreregardless of thefilterTextvalue. This is a fundamental engine difference from LSP4E's subsequence matching.Testing
Tested locally via Extension Development Host against a MicroProfile Gradle project.
Confirmed via
provideCompletionItemmiddleware logging thatitem.detailcarries the human-readable string and that rewritingfilterTextto it produces correct fuzzy matches.Fixes OpenLiberty/liberty-tools-vscode#341
and Fixes #609