File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
src/tools/rust-analyzer/editors/code/src Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -392,14 +392,18 @@ function isCodeActionWithoutEditsAndCommands(value: any): boolean {
392392// to proxy around that. We store the last hover's reference command link
393393// here, as only one hover can be active at a time, and we don't need to
394394// keep a history of these.
395- export let HOVER_REFERENCE_COMMAND : ra . CommandLink | undefined = undefined ;
395+ export let HOVER_REFERENCE_COMMAND : ra . CommandLink [ ] = [ ] ;
396396
397397function renderCommand ( cmd : ra . CommandLink ) : string {
398- HOVER_REFERENCE_COMMAND = cmd ;
399- return `[${ cmd . title } ](command:rust-analyzer.hoverRefCommandProxy '${ cmd . tooltip } ')` ;
398+ HOVER_REFERENCE_COMMAND . push ( cmd ) ;
399+ return `[${ cmd . title } ](command:rust-analyzer.hoverRefCommandProxy?${
400+ HOVER_REFERENCE_COMMAND . length - 1
401+ } '${ cmd . tooltip } ')`;
400402}
401403
402404function renderHoverActions ( actions : ra . CommandLinkGroup [ ] ) : vscode . MarkdownString {
405+ // clean up the previous hover ref command
406+ HOVER_REFERENCE_COMMAND = [ ] ;
403407 const text = actions
404408 . map (
405409 ( group ) =>
Original file line number Diff line number Diff line change @@ -1203,9 +1203,10 @@ export function newDebugConfig(ctx: CtxInit): Cmd {
12031203}
12041204
12051205export function hoverRefCommandProxy ( _ : Ctx ) : Cmd {
1206- return async ( ) => {
1207- if ( HOVER_REFERENCE_COMMAND ) {
1208- const { command, arguments : args = [ ] } = HOVER_REFERENCE_COMMAND ;
1206+ return async ( index : number ) => {
1207+ const link = HOVER_REFERENCE_COMMAND [ index ] ;
1208+ if ( link ) {
1209+ const { command, arguments : args = [ ] } = link ;
12091210 await vscode . commands . executeCommand ( command , ...args ) ;
12101211 }
12111212 } ;
You can’t perform that action at this time.
0 commit comments