Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support multiple tab stops for completions in VSCode #16475

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

DropDemBits
Copy link
Contributor

@DropDemBits DropDemBits commented Feb 2, 2024

Uses the native VSCode support for SnippetTextEdits. Fixes #13229 and fixes #8531.

native-snippet-edits.mp4

This is done in a slightly hacky way, as vscode-languageclient can't convert RA's SnippetTextEdits into vscode SnippetTextEdits and will appear to use a different format in the future.


Marked as draft since as-is, this will cause completions to double-indent any multi-line code generated.
Update: This also fixes up edits so that any multi-line code won't be double-indented.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2024
@DropDemBits DropDemBits force-pushed the native-vscode-snippet-text-edit branch 2 times, most recently from 8753228 to 024f8b0 Compare February 2, 2024 05:37
@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 9, 2024
@DropDemBits DropDemBits force-pushed the native-vscode-snippet-text-edit branch from 024f8b0 to b0f4e07 Compare February 15, 2024 04:32
Uses the native VSCode support for `SnippetTextEdit`s, but in a semi-hacky way as it's not fully supported yet.
We can't tell vscode to not add in the extra indentation, so we instead opt to remove it from the edits themselves, and then let vscode add it back in.
@DropDemBits DropDemBits force-pushed the native-vscode-snippet-text-edit branch from b0f4e07 to bcf14e2 Compare February 15, 2024 23:39
@DropDemBits DropDemBits marked this pull request as ready for review February 15, 2024 23:44
@DropDemBits
Copy link
Contributor Author

Added the double indentation workaround.

Initially decided to try and do the workaround in the server, but that turned out to be impossible 😅
Turns out it was easier to do in the client since in there we have access to the indentation that would've been added on on top.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 15, 2024
@Veykril
Copy link
Member

Veykril commented Feb 19, 2024

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Feb 19, 2024

📌 Commit bcf14e2 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Feb 19, 2024

⌛ Testing commit bcf14e2 with merge 60982dc...

@bors
Copy link
Collaborator

bors commented Feb 19, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 60982dc to master...

@bors bors merged commit 60982dc into rust-lang:master Feb 19, 2024
1 check passed
bors added a commit that referenced this pull request Feb 20, 2024
…-curly, r=Veykril

fix: Don't add `\` before `{`

Fixes #16607 for `{`. The `}` case is already fixed by #16475.

The [LSP snippet grammar](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`.
bors added a commit that referenced this pull request Feb 20, 2024
…-curly, r=Veykril

fix: Don't add `\` before `{`

Fixes #16607 for `{`. The `}` case is already fixed by #16475.

The [LSP snippet grammar](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
4 participants