Skip to content

Commit

Permalink
Add vscode support for gotoRelevantFile
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-codes committed Jan 27, 2025
1 parent 8418db8 commit fb30abd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,23 @@
"command": "rubyLsp.fileOperation",
"when": "rubyLsp.activated && view == 'workbench.explorer.fileView'",
"group": "navigation"
},
{
"command": "rubyLsp.gotoRelevantFile",
"when": "rubyLsp.activated && view == 'workbench.explorer.fileView'",
"group": "navigation"
}
],
"explorer/context": [
{
"command": "rubyLsp.fileOperation",
"when": "rubyLsp.activated",
"group": "2_workspace"
},
{
"command": "rubyLsp.gotoRelevantFile",
"when": "rubyLsp.activated",
"group": "2_workspace"
}
]
},
Expand Down Expand Up @@ -149,6 +159,11 @@
"category": "Ruby LSP",
"icon": "$(ruby)"
},
{
"command": "rubyLsp.gotoRelevantFile",
"title": "Goto relevant file (test <> source code)",
"category": "Ruby LSP"
},
{
"command": "rubyLsp.collectRubyLspInfo",
"title": "Collect Ruby LSP information for issue reporting",
Expand Down
8 changes: 8 additions & 0 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ export default class Client extends LanguageClient implements ClientInterface {
});
}

async sendGotoRelevantFileRequest(
uri: vscode.Uri,
): Promise<{ locations: string[] } | null> {
return this.sendRequest("experimental/gotoRelevantFile", {
textDocument: { uri: uri.toString() },
});
}

private async benchmarkMiddleware<T>(
type: string | MessageSignature,
params: any,
Expand Down
1 change: 1 addition & 0 deletions vscode/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export enum Command {
StartServerInDebugMode = "rubyLsp.startServerInDebugMode",
ShowOutput = "rubyLsp.showOutput",
MigrateLaunchConfiguration = "rubyLsp.migrateLaunchConfiguration",
GotoRelevantFile = "rubyLsp.gotoRelevantFile",
}

export interface RubyInterface {
Expand Down
14 changes: 14 additions & 0 deletions vscode/src/rubyLsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,20 @@ export class RubyLsp {
await workspace?.start(true);
},
),
vscode.commands.registerCommand(Command.GotoRelevantFile, async () => {
const uri = vscode.window.activeTextEditor?.document.uri;
if (!uri) {
return;
}
const response: { locations: string[] } | null | undefined =
await this.currentActiveWorkspace()?.lspClient?.sendGotoRelevantFileRequest(
uri,
);

if (response) {
return openUris(response.locations);
}
}),
);
vscode.commands.registerCommand(Command.ShowOutput, async () => {
LOG_CHANNEL.show();
Expand Down

0 comments on commit fb30abd

Please sign in to comment.