Skip to content

Commit 8420c92

Browse files
ono-maxko1
authored andcommitted
Use short name in path for each tree item
1 parent b0dcf12 commit 8420c92

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/rdbgTreeItem.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class RecordLogItem extends BaseLogItem {
110110
state?: vscode.TreeItemCollapsibleState,
111111
)
112112
{
113-
const description = log.location.path + ":" + log.location.line;
113+
const description = prettyPath(log.location.path) + ":" + log.location.line;
114114
const opts: RdbgTreeItemOptions = { collapsibleState: state };
115115
opts.collapsibleState = state;
116116
opts.description = description;
@@ -121,6 +121,15 @@ export class RecordLogItem extends BaseLogItem {
121121
}
122122
}
123123

124+
function prettyPath(path: string) {
125+
const relative = vscode.workspace.asRelativePath(path);
126+
const home = process.env.HOME;
127+
if (home) {
128+
return relative.replace(home, "~");
129+
}
130+
return relative;
131+
}
132+
124133
export class TraceLogItem extends BaseLogItem {
125134
constructor(
126135
label: string,
@@ -138,8 +147,9 @@ const locationIcon = new vscode.ThemeIcon("location");
138147

139148
export class LineTraceLogItem extends TraceLogItem {
140149
constructor(log: TraceLog, idx: number, state?: vscode.TreeItemCollapsibleState) {
141-
const label = log.location.path + ":" + log.location.line.toString();
142-
const opts: RdbgTreeItemOptions = { iconPath: locationIcon, collapsibleState: state };
150+
const label = prettyPath(log.location.path) + ":" + log.location.line.toString();
151+
const tooltip = log.location.path;
152+
const opts: RdbgTreeItemOptions = { iconPath: locationIcon, collapsibleState: state , tooltip};
143153
super(label, idx, log.depth, log.location, log.threadId, opts);
144154
}
145155
}
@@ -156,7 +166,7 @@ export class CallTraceLogItem extends TraceLogItem {
156166
} else {
157167
iconPath = arrowCircleRight;
158168
}
159-
const description = log.location.path + ":" + log.location.line;
169+
const description = prettyPath(log.location.path) + ":" + log.location.line;
160170
const opts: RdbgTreeItemOptions = { iconPath: iconPath, collapsibleState: state, description };
161171
super(log.name || "Unknown frame name", idx, log.depth, log.location, log.threadId, opts);
162172
this.returnValue = log.returnValue;

0 commit comments

Comments
 (0)