Bug Report
Component: deps-cargo (feature name auto-completion, PR #83)
Severity: P1
Description
complete_features() passes Range::default() (= position (0,0)-(0,0)) as insert_range to build_feature_completion. This creates a textEdit with an empty range at the document start. Per LSP spec, textEdit takes precedence over insertText, so a strict client would insert the feature name at the beginning of the file instead of at the cursor, corrupting the manifest.
complete_versions_generic avoids this by passing None for the range, omitting textEdit entirely and letting the client use insertText at the cursor position.
Reproduction
[dependencies]
serde = { version = "1", features = ["de"] }
- Place cursor at position (6, 39) — inside
"de"
- Trigger completion
- Apply the
default completion item
Expected: features = ["default"]
Actual: default is prepended to line 0, char 0 — corrupting the manifest
LSP trace evidence
textEdit={"newText": "default", "range": {"end": {"character": 0, "line": 0}, "start": {"character": 0, "line": 0}}}
Root cause
crates/deps-cargo/src/ecosystem.rs:79:
let insert_range = tower_lsp_server::ls_types::Range::default();
Compare with the correct pattern in complete_versions_generic:
// Don't provide text_edit range - let LSP client insert at cursor position
.map(|item| build_version_completion(item, None))
Fix
Change build_feature_completion to accept Option<Range> (like build_version_completion) and omit textEdit when range is unknown. Pass None from complete_features.
Bug Report
Component: deps-cargo (feature name auto-completion, PR #83)
Severity: P1
Description
complete_features()passesRange::default()(= position (0,0)-(0,0)) asinsert_rangetobuild_feature_completion. This creates atextEditwith an empty range at the document start. Per LSP spec,textEdittakes precedence overinsertText, so a strict client would insert the feature name at the beginning of the file instead of at the cursor, corrupting the manifest.complete_versions_genericavoids this by passingNonefor the range, omittingtextEditentirely and letting the client useinsertTextat the cursor position.Reproduction
"de"defaultcompletion itemExpected:
features = ["default"]Actual:
defaultis prepended to line 0, char 0 — corrupting the manifestLSP trace evidence
Root cause
crates/deps-cargo/src/ecosystem.rs:79:Compare with the correct pattern in
complete_versions_generic:Fix
Change
build_feature_completionto acceptOption<Range>(likebuild_version_completion) and omittextEditwhen range is unknown. PassNonefromcomplete_features.