[Lldb-commits] [lldb] [lldb-dap] Support vscode launch URLs (PR #125843)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 5 16:07:56 PST 2025
================
@@ -0,0 +1,37 @@
+import * as vscode from "vscode";
+
+export class LaunchUriHandler implements vscode.UriHandler {
+ async handleUri(uri: vscode.Uri) {
+ try {
+ const params = new URLSearchParams(uri.query);
+ if (uri.path == '/launch/config') {
----------------
ashgti wrote:
Should we shorten the path to `/launch`? We already are using the param `config` so having that twice feels a little redundant.
Or we could take the search params as keys into the launch config like:
```ts
const launchConfig = {...};
const url = new URL("vscode://llvm-vs-code-extensions.lldb-dap/launch?program=/a.out&initCommands=a&initCommands=b")
const stringKeys = ["program"];
const numberKeys = ["pid"];
const arrayKeys = ["initCommands"];
for (const key of stringKeys) {
const value = url.searchParams.get(key);
if (value) {
launchConfig[key] = value;
}
}
for (const key of numberKeys) {
const value = url.searchParams.get(key);
if (value) {
launchConfig[key] = Number(value);
}
}
for (const key of arrayKeys) {
const value = url.searchParams.getAll(key); // note, getAll() returns an array of strings.
if (value) {
launchConfig[key] = value;
}
}
console.log(launchConfig); // => { "program": "/a.out", "initCommands": ["a", "b"] }
```
https://github.com/llvm/llvm-project/pull/125843
More information about the lldb-commits
mailing list