fix: update dependencies and enhance completion logic for Cargo.toml#1604
fix: update dependencies and enhance completion logic for Cargo.toml#1604
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves Cargo.toml completion behavior in the Tombi LSP/extension stack, especially around dependency version insertion when the user triggers completion with =/. or is editing an existing string value, and updates the lockfile to newer dependency versions.
Changes:
- Refines Cargo extension crate-version completion edits to better handle incomplete values and in-string edits.
- Adjusts LSP key extraction to better detect
=/.triggers for key-value contexts. - Adds new completion label/edit regression tests for Cargo dependency version completion scenarios; updates
Cargo.lock.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/tombi-extension-cargo/src/completion.rs | Updates crate-version completion edit generation for String vs Incomplete document-tree values. |
| crates/tombi-lsp/src/completion.rs | Tweaks key extraction and completion-hint detection for key-value nodes near the cursor. |
| crates/tombi-lsp/tests/test_completion_labels.rs | Adds regression tests for Cargo dependency completions; simplifies file-path-to-URL handling. |
| crates/tombi-lsp/tests/test_completion_edit.rs | Adds regression tests ensuring dependency version completion produces the intended text edits; adds SourcePath support. |
| Cargo.lock | Updates resolved dependency versions (lockfile refresh). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| test_completion_edit! { | ||
| #[tokio::test] | ||
| async fn cargo_dependencies_num_chrono_duration_equal( | ||
| r#" | ||
| [dependencies] | ||
| num-chrono-duration=█ | ||
| "#, | ||
| Select("\"0.1.0\""), | ||
| SourcePath(project_root_path().join("Cargo.toml")), | ||
| SchemaPath(cargo_schema_path()), | ||
| ) -> Ok( | ||
| r#" | ||
| [dependencies] | ||
| num-chrono-duration = "0.1.0" | ||
| "# | ||
| ); |
There was a problem hiding this comment.
These new edit tests select a specific crate version label ("0.1.0") for dependency completions. If the version list is sourced from crates.io at runtime, the latest version can change (or be unavailable offline), making the test suite flaky. Consider mocking/stubbing the version provider in tests, or asserting a more stable property (e.g., that the applied edit produces a valid = "<semver>" requirement) rather than pinning to an exact live version string.
| SourcePath(project_root_path().join("Cargo.toml")), | ||
| SchemaPath(cargo_schema_path()), | ||
| ) -> Ok([ | ||
| "\"0.1.0\"", |
There was a problem hiding this comment.
These new completion expectations assert an exact crate version string ("0.1.0"). That value appears to come from the Cargo schema’s crates-version integration (and the cargo extension’s crates.io lookup), so it can change when the crate publishes a new release or when CI runs without network access. Consider mocking/stubbing the crates.io version provider for tests, or loosening assertions to avoid depending on live registry data (e.g., assert that at least one quoted semver requirement is suggested, rather than a specific version).
| "\"0.1.0\"", |
No description provided.