================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to