diff --git a/src/extension.ts b/src/extension.ts index 959bc14c..46956ee3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -22,7 +22,7 @@ import { import { DebugProtocol } from "@vscode/debugprotocol"; import { registerInspectorView } from "./inspector"; import { AttachConfiguration, LaunchConfiguration } from "./config"; -import { VersionChecker } from "./utils"; +import { VersionChecker, fullPath } from "./utils"; const asyncExec = promisify(child_process.exec); @@ -483,7 +483,7 @@ class RdbgAdapterDescriptorFactory implements DebugAdapterDescriptorFactory, Ver } if (sockPath) { - return new DebugAdapterNamedPipeServer(sockPath); + return new DebugAdapterNamedPipeServer(fullPath(sockPath, session)); } else if (port) { return new vscode.DebugAdapterServer(port, host); diff --git a/src/rdbgTreeItem.ts b/src/rdbgTreeItem.ts index be59fea0..06feef47 100644 --- a/src/rdbgTreeItem.ts +++ b/src/rdbgTreeItem.ts @@ -10,9 +10,7 @@ import { RdbgInspectorCommand, BaseLog, } from "./protocol"; -import { customRequest } from "./utils"; -import * as path from "path"; -import * as fs from "fs"; +import { customRequest, fullPath } from "./utils"; export type RdbgTreeItemOptions = Pick< vscode.TreeItem, @@ -112,7 +110,7 @@ export class RecordLogItem extends BaseLogItem { state?: vscode.TreeItemCollapsibleState, ) { - log.location.path = fullPath(log.location.path); + log.location.path = fullPath(log.location.path, vscode.debug.activeDebugSession); const description = prettyPath(log.location.path) + ":" + log.location.line; const opts: RdbgTreeItemOptions = { collapsibleState: state }; opts.collapsibleState = state; @@ -150,7 +148,7 @@ const locationIcon = new vscode.ThemeIcon("location"); export class LineTraceLogItem extends TraceLogItem { constructor(log: TraceLog, idx: number, state?: vscode.TreeItemCollapsibleState) { - log.location.path = fullPath(log.location.path); + log.location.path = fullPath(log.location.path, vscode.debug.activeDebugSession); const label = prettyPath(log.location.path) + ":" + log.location.line.toString(); const tooltip = log.location.path; const opts: RdbgTreeItemOptions = { iconPath: locationIcon, collapsibleState: state , tooltip}; @@ -164,7 +162,7 @@ export class CallTraceLogItem extends TraceLogItem { public readonly returnValue: TraceLog["returnValue"]; public readonly parameters: TraceLog["parameters"]; constructor(log: TraceLog, idx: number, state?: vscode.TreeItemCollapsibleState) { - log.location.path = fullPath(log.location.path); + log.location.path = fullPath(log.location.path, vscode.debug.activeDebugSession); let iconPath: vscode.ThemeIcon; if (log.returnValue) { iconPath = arrowCircleLeft; @@ -277,18 +275,3 @@ export class ToggleTreeItem extends RdbgTreeItem { this._enabledCommand = undefined; } } - -function fullPath(p: string) { - if (path.isAbsolute(p)) { - return p; - } - const workspace = vscode.debug.activeDebugSession?.workspaceFolder; - if (workspace === undefined) { - return p; - } - const fullPath = path.join(workspace.uri.fsPath, p); - if (fs.existsSync(fullPath)) { - return fullPath; - } - return p; -} diff --git a/src/utils.ts b/src/utils.ts index 1cdab818..4327b0db 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,7 @@ import * as vscode from "vscode"; import { LaunchConfiguration } from "./config"; +import * as path from "path"; +import * as fs from "fs"; export async function customRequest(session: vscode.DebugSession, command: string, args?: any) { try { @@ -14,3 +16,18 @@ export interface VersionChecker { getVersion(config: LaunchConfiguration): Promise; vernum(version: string): number; } + +export function fullPath(p: string, session: vscode.DebugSession | undefined) { + if (path.isAbsolute(p)) { + return p; + } + const workspace = session?.workspaceFolder; + if (workspace === undefined) { + return p; + } + const fullPath = path.join(workspace.uri.fsPath, p); + if (fs.existsSync(fullPath)) { + return fullPath; + } + return p; +}