diff options
| author | bors <bors@rust-lang.org> | 2024-07-11 08:55:34 +0000 |
|---|---|---|
| committer | Josh McKinney <joshka@users.noreply.github.com> | 2024-07-12 19:06:19 -0700 |
| commit | 377a0a7696bbd33c38ac418e8c75428a147eb688 (patch) | |
| tree | e8117f19c37b67d06c3d77f2066425b06fd13470 /src/tools/rust-analyzer/editors/code | |
| parent | 45609a995e766d614da694d353f7aee03820b0f9 (diff) | |
Trigger VSCode to rename after extract variable assist is applied
When the user applies the "Extract Variable" assist, the cursor is positioned at the newly inserted variable. This commit adds a command to the assist that triggers the rename action in VSCode. This way, the user can quickly rename the variable after applying the assist. Fixes part of: #17579
Diffstat (limited to 'src/tools/rust-analyzer/editors/code')
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/client.ts | 1 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/commands.ts | 6 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/main.ts | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/client.ts b/src/tools/rust-analyzer/editors/code/src/client.ts index 542233e7b91..1599f4b13ae 100644 --- a/src/tools/rust-analyzer/editors/code/src/client.ts +++ b/src/tools/rust-analyzer/editors/code/src/client.ts @@ -348,6 +348,7 @@ class ExperimentalFeatures implements lc.StaticFeature { "rust-analyzer.showReferences", "rust-analyzer.gotoLocation", "editor.action.triggerParameterHints", + "editor.action.rename", ], }, ...capabilities.experimental, diff --git a/src/tools/rust-analyzer/editors/code/src/commands.ts b/src/tools/rust-analyzer/editors/code/src/commands.ts index 2b0b3001062..72ca2923dda 100644 --- a/src/tools/rust-analyzer/editors/code/src/commands.ts +++ b/src/tools/rust-analyzer/editors/code/src/commands.ts @@ -118,6 +118,12 @@ export function triggerParameterHints(_: CtxInit): Cmd { }; } +export function rename(_: CtxInit): Cmd { + return async () => { + await vscode.commands.executeCommand("editor.action.rename"); + }; +} + export function openLogs(ctx: CtxInit): Cmd { return async () => { if (ctx.client.outputChannel) { diff --git a/src/tools/rust-analyzer/editors/code/src/main.ts b/src/tools/rust-analyzer/editors/code/src/main.ts index c96f2ae869e..a23f3656e3b 100644 --- a/src/tools/rust-analyzer/editors/code/src/main.ts +++ b/src/tools/rust-analyzer/editors/code/src/main.ts @@ -190,6 +190,7 @@ function createCommands(): Record<string, CommandFactory> { runSingle: { enabled: commands.runSingle }, showReferences: { enabled: commands.showReferences }, triggerParameterHints: { enabled: commands.triggerParameterHints }, + rename: { enabled: commands.rename }, openLogs: { enabled: commands.openLogs }, revealDependency: { enabled: commands.revealDependency }, }; |
