Skip to content

Commit 29add0d

Browse files
ono-maxko1
authored andcommitted
Set a full path of the file name if it is a relave path
1 parent 8420c92 commit 29add0d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/rdbgTreeItem.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
BaseLog,
1212
} from "./protocol";
1313
import { customRequest } from "./utils";
14+
import * as path from "path";
15+
import * as fs from "fs";
1416

1517
export type RdbgTreeItemOptions = Pick<
1618
vscode.TreeItem,
@@ -110,6 +112,7 @@ export class RecordLogItem extends BaseLogItem {
110112
state?: vscode.TreeItemCollapsibleState,
111113
)
112114
{
115+
log.location.path = fullPath(log.location.path);
113116
const description = prettyPath(log.location.path) + ":" + log.location.line;
114117
const opts: RdbgTreeItemOptions = { collapsibleState: state };
115118
opts.collapsibleState = state;
@@ -147,6 +150,7 @@ const locationIcon = new vscode.ThemeIcon("location");
147150

148151
export class LineTraceLogItem extends TraceLogItem {
149152
constructor(log: TraceLog, idx: number, state?: vscode.TreeItemCollapsibleState) {
153+
log.location.path = fullPath(log.location.path);
150154
const label = prettyPath(log.location.path) + ":" + log.location.line.toString();
151155
const tooltip = log.location.path;
152156
const opts: RdbgTreeItemOptions = { iconPath: locationIcon, collapsibleState: state , tooltip};
@@ -160,6 +164,7 @@ export class CallTraceLogItem extends TraceLogItem {
160164
public readonly returnValue: TraceLog["returnValue"];
161165
public readonly parameters: TraceLog["parameters"];
162166
constructor(log: TraceLog, idx: number, state?: vscode.TreeItemCollapsibleState) {
167+
log.location.path = fullPath(log.location.path);
163168
let iconPath: vscode.ThemeIcon;
164169
if (log.returnValue) {
165170
iconPath = arrowCircleLeft;
@@ -272,3 +277,18 @@ export class ToggleTreeItem extends RdbgTreeItem {
272277
this._enabledCommand = undefined;
273278
}
274279
}
280+
281+
function fullPath(p: string) {
282+
if (path.isAbsolute(p)) {
283+
return p;
284+
}
285+
const workspace = vscode.debug.activeDebugSession?.workspaceFolder;
286+
if (workspace === undefined) {
287+
return p;
288+
}
289+
const fullPath = path.join(workspace.uri.fsPath, p);
290+
if (fs.existsSync(fullPath)) {
291+
return fullPath;
292+
}
293+
return p;
294+
}

0 commit comments

Comments
 (0)