Skip to content

fix(deps-cargo): omit textEdit in feature completions to avoid cursor corruption#90

Merged
bug-ops merged 1 commit intomainfrom
88-feature-completion-range
Mar 28, 2026
Merged

fix(deps-cargo): omit textEdit in feature completions to avoid cursor corruption#90
bug-ops merged 1 commit intomainfrom
88-feature-completion-range

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 28, 2026

Summary

  • complete_features() was passing Range::default() (position (0,0)-(0,0)) to build_feature_completion, generating a textEdit with an empty range at the document start
  • Per LSP spec, textEdit takes precedence over insertText, so strict clients inserted the feature name at the beginning of the file instead of the cursor — corrupting the manifest
  • Changed build_feature_completion to accept Option<Range> and omit textEdit when None, matching the existing pattern in complete_versions_generic

Test plan

  • cargo nextest run -p deps-core -E 'test(feature_completion)' — new test_build_feature_completion asserts text_edit.is_none() when None range is passed; test_build_feature_completion_with_range covers the Some(range) path
  • Full workspace tests pass: cargo nextest run --workspace --all-features --lib --bins
  • Open a Cargo.toml with serde = { version = "1", features = ["de"] }, place cursor inside "de", trigger completion, apply a feature — text appears at cursor, not at line 0

Closes #88

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes needs-review Needs review size: S 10-50 lines changed labels Mar 28, 2026
… corruption

complete_features() was passing Range::default() (position 0,0-0,0) as
insert_range to build_feature_completion, producing a textEdit that,
per LSP spec, takes precedence over insertText and inserts the feature name
at the beginning of the file instead of the cursor position.

Change build_feature_completion to accept Option<Range> and omit textEdit
entirely when None is passed, matching the behaviour of complete_versions_generic.
Pass None from complete_features.

Closes #88
@bug-ops bug-ops force-pushed the 88-feature-completion-range branch from 6bb8891 to 7dd2802 Compare March 28, 2026 21:17
@bug-ops bug-ops enabled auto-merge (squash) March 28, 2026 21:18
@bug-ops bug-ops merged commit d175e77 into main Mar 28, 2026
20 checks passed
@bug-ops bug-ops deleted the 88-feature-completion-range branch March 28, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation needs-review Needs review rust Rust code changes size: S 10-50 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(deps-cargo): feature completion textEdit has wrong range (0,0)-(0,0)

1 participant