fix: add context-aware SPDX and pragma completions#224
Open
rifuki wants to merge 2 commits into
Open
Conversation
mmsaki
reviewed
Jun 8, 2026
Collaborator
There was a problem hiding this comment.
Looks like you need to specify the start and end to replace if we need the version completions.
pragma solidity 0.*| ^0.8.35;
// ^ completion cursor
Author
There was a problem hiding this comment.
Fixed in 6a4663e. Version completions now use a text edit from the start of the pragma solidity value through the end of the existing version expression before ;. So the example pragma solidity 0.*| ^0.8.35; is replaced as a whole value and becomes pragma solidity ^0.8.35;, instead of inserting at the cursor or duplicating the trailing text.
Added test_context_completion_pragma_solidity_version_replaces_partial_token for this exact shape.
Verified with:
cargo check
cargo test --test completion test_context_completion
cargo test --test completion
cargo test919c1ff to
6a4663e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #223
Problem
Completion inside source-unit directive contexts can fall through to normal/global Solidity completions. This makes early SPDX and pragma typing noisy, and SPDX insertion can duplicate the existing
//prefix depending on the client.Fix
// S,// SP,// SPD, and// SPDX.pragma,pragma solidity, andpragma abicodercontexts.Tests
rustfmt src/completion.rs tests/completion.rscargo checkcargo test --test completion -- --nocapturecargo test --lib -- --nocapturecargo testcargo build --release --bin solidity-language-servergit diff --check