Skip to content

fix: update dependencies and enhance completion logic for Cargo.toml#1604

Merged
ya7010 merged 1 commit intomainfrom
update_completion_logic
Mar 20, 2026
Merged

fix: update dependencies and enhance completion logic for Cargo.toml#1604
ya7010 merged 1 commit intomainfrom
update_completion_logic

Conversation

@ya7010
Copy link
Copy Markdown
Collaborator

@ya7010 ya7010 commented Mar 20, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 20, 2026 04:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +123 to +138
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"
"#
);
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
SourcePath(project_root_path().join("Cargo.toml")),
SchemaPath(cargo_schema_path()),
) -> Ok([
"\"0.1.0\"",
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
"\"0.1.0\"",

Copilot uses AI. Check for mistakes.
@ya7010 ya7010 merged commit 2b90077 into main Mar 20, 2026
27 checks passed
@ya7010 ya7010 deleted the update_completion_logic branch March 20, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants