Skip to content

Commit 994f4f6

Browse files
committed
Auto merge of #15290 - igorskyflyer:igorskyflyer-dx-install-extension, r=lnicola
editor/code: [DX] Use notification command links for debugger installation This PR improves DX (developer experience) when installing the VS Code extension for the first time. When doing so and trying to debug a Rust file, we get an error notification that either CodeLLDB or C++ extension/debugger should be installed (see image below). <div align="center"> <img src="https://github.com/rust-lang/rust-analyzer/assets/20957750/e8ebeb1e-85f4-44e2-b79f-c48cf52e5f36" alt="Rust, prompt to install debug extension"> </div> The PR enhances the links in the given notification and upon clicking instead of opening the Web page of the extension it installs the extension immediately, without the need to leave the editor. Note: the feature needs to be refined, maybe an "install in progress" message or something similar, I left that for you guys to decide and implement. I think it also possible to first open the sidebar, open the Extensions tab, then run the extension installation command which would make it more user-friendly. P.S. it is also possible to open the extension's details in VS Code directly via the same links and then the user would have to manually click on the Install button - if installation is not the desired behavior. Happy coding! 🎉
2 parents be82869 + 5d67cbe commit 994f4f6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

editors/code/src/debug.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export async function startDebugSession(ctx: Ctx, runnable: ra.Runnable): Promis
6666
return vscode.debug.startDebugging(undefined, debugConfig);
6767
}
6868

69+
function createCommandLink(extensionId: string): string {
70+
// do not remove the second quotes inside
71+
// encodeURIComponent or it won't work
72+
return `extension.open?${encodeURIComponent(`"${extensionId}"`)}`;
73+
}
74+
6975
async function getDebugConfiguration(
7076
ctx: Ctx,
7177
runnable: ra.Runnable,
@@ -90,9 +96,12 @@ async function getDebugConfiguration(
9096
}
9197

9298
if (!debugEngine) {
99+
const commandCodeLLDB: string = createCommandLink("vadimcn.vscode-lldb");
100+
const commandCpp: string = createCommandLink("ms-vscode.cpptools");
101+
93102
await vscode.window.showErrorMessage(
94-
`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)` +
95-
` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`,
103+
`Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` +
104+
` or [C/C++](command:${commandCpp} "Open C/C++") extension for debugging.`,
96105
);
97106
return;
98107
}

0 commit comments

Comments
 (0)