fix(lsp): dotted-key completion fixes + complete [tasks.overrides] keys with project task names#85
Merged
Merged
Conversation
…n via text edit A dotted key (`group_output.`) hit the plain Key path and offered the section's entire field list — TOML reads the dot as a key *path*, and no section has enumerable sub-keys (`[tasks].overrides` entries are user-chosen names). Dotted keys now complete nothing. Key completions also carried only insert_text, anchored wherever the client's word detection put them: a list left open across a backspace kept its old zero-width anchor and pasted wholesale (`group_outputgroup_output = `). Items now carry an explicit text edit spanning the typed token, so accepting can only substitute it.
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
🚫 Excluded labels (none allowed) (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Entry keys under [tasks.overrides] (and dotted overrides.<task> keys in
[tasks]) are the project's own task names — complete them from the same
detection the CLI runs, anchored at the document's directory. Each item
carries its source label and description; names that aren't bare TOML
keys insert quoted ("build:web" = ). Dotted overrides.<task> values
now route to the source-label vocabulary like their [tasks.overrides]
equivalents.
…uoting Key completions now scaffold the value shape the field's schema type calls for, gated on the client's declared snippet support (read from initialize, previously discarded): arrays insert name = ["$0"], strings name = "$0", others a bare tab stop. Table fields continue the dotted key path (overrides.) so completion re-triggers with task names. Non-snippet clients keep the plain name-equals insert. Value completions inside an open string literal (prefer = ["ba) now insert the bare word — the quotes are already typed (and auto-paired by the editor), so the quoted insert produced ""bacon"". FieldDoc's shape flags collapse into a FieldType enum (a field has one JSON type shape; four bools tripped clippy's struct_excessive_bools and could express impossible states).
The line-shape analyzer had no comment notion: '# prefer = ' classified as a value line and popped completions inside comments. A cursor at or after a '#' outside a string literal now reads as a comment — no completions, no hover; '#' inside a "..."/'...' value stays a value character.
key_token advanced past whitespace by one byte; a multibyte whitespace char (U+3000) before the key split the codepoint and panicked the completion request. Advance by the matched char's UTF-8 length. document_dir used the raw URI path: percent-encoded segments (spaces, non-ASCII) resolved to nonexistent directories and killed task discovery, and the /C:/ drive form failed is_absolute on Windows. Decode via fluent-uri's EStr and strip the drive-form slash (unix then rejects it at the is_absolute filter as before). Adds unit coverage for client_supports_snippets (nested capability, absent/false, malformed params) and the document_dir variants.
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.
Two completion defects around dotted keys, plus the feature they were blocking:
group_output.offered the section's whole field list. Theline-shape analyzer classified it as a plain key and never looked at
the typed token; TOML reads the dot as a key path. A dotted key now
completes nothing — except
overrides.(below).(
group_outputgroup_output =). Items carried onlyinsertText,anchored wherever the client's word detection put them — a list left
open across a backspace kept its old zero-width anchor at the deleted
dot and pasted wholesale. Key completions now carry an explicit
textEditspanning the typed token, so accepting can onlysubstitute it.
[tasks.overrides]entry keys now complete with the project's owntask names, discovered from the document's directory with the same
detection the CLI runs. Each item carries its source label and
description; names that aren't bare TOML keys insert quoted
(
"build:web" =). Works under the[tasks.overrides]header andas a dotted
overrides.<task>key in[tasks]; dotted valuescomplete the source-label vocabulary like their
[tasks.overrides]equivalents.
Test plan
document_dirfile-URI parent + non-file rejection)cargo test --all-featuresgreen (903), clippy-D warnings -D clippy::allclean,cargo fmt --checkclean