Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@vscode/debugadapter": "^1.68.0",
"@vscode/debugprotocol": "^1.68.0",
"@vscode/vsce": "^3.9.1",
"esbuild": "^0.28.0",
"esbuild": "0.28.0",
"eslint": "^10.2.1",
"get-port": "^7.2.0",
"glob": "^13.0.6",
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
resolveRemoteServerMode,
uploadClientFiles,
} from './remoteServer';
import {UriLaunchServer} from './externalLaunch';

export async function activate(context: vscode.ExtensionContext) {
const descriptorFactory = new ProbeRSDebugAdapterServerDescriptorFactory();
Expand All @@ -39,6 +40,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.debug.onDidReceiveDebugSessionCustomEvent(
descriptorFactory.receivedCustomEvent.bind(descriptorFactory),
),
vscode.window.registerUriHandler(new UriLaunchServer()),
);

(async () => {
Expand Down
44 changes: 44 additions & 0 deletions src/externalLaunch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as querystring from 'querystring';
import {debug, Uri, UriHandler, window, workspace, DebugConfiguration} from 'vscode';

interface Dict<T> {
[key: string]: T;
}

export class UriLaunchServer implements UriHandler {
async handleUri(uri: Uri) {
try {
if (uri.path === '/launch') {
let params = querystring.parse(uri.query, ',') as Dict<string>;
if (params.folder && params.name) {
let wsFolder = workspace.getWorkspaceFolder(Uri.file(params.folder));
await debug.startDebugging(wsFolder, params.name);
} else if (params.name) {
if (workspace.workspaceFolders) {
// Try all workspace folders
for (let wsFolder of workspace.workspaceFolders) {
if (await debug.startDebugging(wsFolder, params.name)) {
break;
}
}
}
} else {
throw new Error(`Unsupported combination of launch Uri parameters.`);
}
} else if (uri.path === '/launch/config') {
let debugConfig: DebugConfiguration = {
type: 'probe-rs-debug',
request: 'launch',
name: '',
};
Object.assign(debugConfig, JSON.parse(uri.query));
debugConfig.name = debugConfig.name || debugConfig.program;
await debug.startDebugging(undefined, debugConfig);
} else {
throw new Error(`Unsupported Uri path: ${uri.path}`);
}
} catch (err: any) {
await window.showErrorMessage(err.toString());
}
}
}
Loading