fix(properties): scope completion query characters to property nodes#289
Merged
tartarughina merged 1 commit intoJul 22, 2026
Conversation
Typing a dotted key such as `server.p` ranked unrelated deeper keys above `server.port`, because Zed built its fuzzy query from the surrounding word only, and `.` was not a word character for Properties. The query collapsed to `p`, so the server's `sortText` ordering was discarded and the exact prefix match dropped out of the visible list. Declare `completion_query_characters` for the Properties language so the query is the whole dotted key. The setting only takes effect through an override scope, so add the matching `overrides.scm`. The capture must be `.inclusive`: a key is typed left-to-right, so the cursor sits at the end offset of the `property` node, and Zed's `SyntaxLayer::override_id` excludes that offset for non-inclusive captures. Verified in Zed 1.11.3 against a Spring Boot project — with a plain `@property` capture the query stays `p` and `server.port` is absent from the menu; with `@property.inclusive` the query becomes `server.p` and `server.port` ranks first. Fixes zed-extensions#287
Collaborator
|
@luceat-lux-vestra thanks for the PR. Let's please add the issue you opened against Zed for the completions' sorting and could you add screenshots of the before and after? Other than that the code and the testing you've done are good |
Contributor
Author
|
Added the upstream Zed issue and before/after screenshots to the PR description. Thanks for the review! |
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.
Fixes #287.
Problem
Typing a dotted key such as
server.pinapplication.propertiespushesserver.portout of the completion menu entirely, while unrelated deeper keys (server.ssl.key-password,server.tomcat.max-part-header-size) rank at the top.The cause is on the query side, not the ranking side. Zed builds the fuzzy query from the surrounding word at the cursor (
Editor::completion_query→surrounding_word(offset, Some(CharScopeContext::Completion))), and.is not a word character for the Properties language. So atserver.pthe query collapses top, every candidate containing apmatches, and the exact prefix match loses.This is independent of what the server advertises. The completions here come from the Spring Boot Language Server — the same server that backs the VS Code Spring Boot Tools extension — which I reach in Zed through zed-spring-tools. It returns
server.portas its first item withsortText: "00000"; the item is present in the LSP response and simply never surfaces in the menu.Fix
Declare
completion_query_charactersfor Properties so the query is the whole dotted key. As @tartarughina suggested, the override is scoped topropertyrather thanstring. The setting only takes effect through an override scope, so this also adds the matchingoverrides.scm— without it theconfig.tomlblock is inert.The capture must be
.inclusive. A key is typed left-to-right, so the cursor sits at the end offset of thepropertynode, andSyntaxLayer::override_idskips non-inclusive captures whenoffset >= range.end.Verification
Driven in Zed
1.11.3+stable.326against a Spring Boot 3 project with the official Java extension and jdtls running, so the completions are classpath-backed.Cursor at the end of
server.p:overrides.scmpserver.portabsent;server.ssl.key-passwordfirst(property) @propertyp(property) @property.inclusiveserver.pserver.portfirst,server.highlighted on every itemBefore — at
server.p,server.portis absent from the menu andserver.ssl.key-passwordranks first:After — same cursor with
(property) @property.inclusive,server.portis the first item:Known residual
Two things are out of reach from the extension:
sortText—sort_scoreis compared beforesort_textinsort_string_matches, and deprecated items are not deprioritised, so a deprecated key can rank third. I've filed that separately as LSP sortText is effectively ignored when ranking completions zed-industries/zed#61349.