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! 🎉
This commit is contained in:
commit
994f4f6e2e
@ -66,6 +66,12 @@ export async function startDebugSession(ctx: Ctx, runnable: ra.Runnable): Promis
|
|||||||
return vscode.debug.startDebugging(undefined, debugConfig);
|
return vscode.debug.startDebugging(undefined, debugConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCommandLink(extensionId: string): string {
|
||||||
|
// do not remove the second quotes inside
|
||||||
|
// encodeURIComponent or it won't work
|
||||||
|
return `extension.open?${encodeURIComponent(`"${extensionId}"`)}`;
|
||||||
|
}
|
||||||
|
|
||||||
async function getDebugConfiguration(
|
async function getDebugConfiguration(
|
||||||
ctx: Ctx,
|
ctx: Ctx,
|
||||||
runnable: ra.Runnable,
|
runnable: ra.Runnable,
|
||||||
@ -90,9 +96,12 @@ async function getDebugConfiguration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!debugEngine) {
|
if (!debugEngine) {
|
||||||
|
const commandCodeLLDB: string = createCommandLink("vadimcn.vscode-lldb");
|
||||||
|
const commandCpp: string = createCommandLink("ms-vscode.cpptools");
|
||||||
|
|
||||||
await vscode.window.showErrorMessage(
|
await vscode.window.showErrorMessage(
|
||||||
`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)` +
|
`Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` +
|
||||||
` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`,
|
` or [C/C++](command:${commandCpp} "Open C/C++") extension for debugging.`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user