Skip to content

fix(lsp): dotted-key completion fixes + complete [tasks.overrides] keys with project task names#85

Merged
kjanat merged 5 commits into
masterfrom
lsp-dotted-key-completion
Jul 5, 2026
Merged

fix(lsp): dotted-key completion fixes + complete [tasks.overrides] keys with project task names#85
kjanat merged 5 commits into
masterfrom
lsp-dotted-key-completion

Conversation

@kjanat

@kjanat kjanat commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Two completion defects around dotted keys, plus the feature they were blocking:

  • group_output. offered the section's whole field list. The
    line-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).
  • Accepting from a stale list doubled the key
    (group_outputgroup_output = ). Items carried only insertText,
    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
    textEdit spanning the typed token, so accepting can only
    substitute it.
  • [tasks.overrides] entry keys now complete with the project's own
    task 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 and
    as a dotted overrides.<task> key in [tasks]; dotted values
    complete the source-label vocabulary like their [tasks.overrides]
    equivalents.

Test plan

  • 7 new unit tests (dotted key → empty; text-edit token replacement; task-name keys from a temp project incl. quoting; dotted-key task names after the dot; dotted-value labels; document_dir file-URI parent + non-file rejection)
  • cargo test --all-features green (903), clippy -D warnings -D clippy::all clean, cargo fmt --check clean

…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.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • cr:review
🚫 Excluded labels (none allowed) (2)
  • wip
  • cr:skip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 26047005-a0c0-46d1-a0a1-afe4efde1e84

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

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.
@kjanat kjanat changed the title fix(lsp): no field completions after a dotted key, replace typed token via text edit fix(lsp): dotted-key completion fixes + complete [tasks.overrides] keys with project task names Jul 5, 2026
kjanat added 2 commits July 5, 2026 15:12
…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.
@kjanat kjanat self-assigned this Jul 5, 2026
@coderabbitai coderabbitai Bot added area: cli Argument parsing, commands, and CLI UX enhancement New feature or request labels Jul 5, 2026
coderabbitai[bot]

This comment was marked as resolved.

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.
@kjanat kjanat merged commit 43dd5da into master Jul 5, 2026
18 checks passed
@kjanat kjanat deleted the lsp-dotted-key-completion branch July 5, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Argument parsing, commands, and CLI UX enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant