Skip to content

Commit 244d2a1

Browse files
committed
Fix relative path from . in browser
1 parent 63eb31c commit 244d2a1

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/view/treeNodes/fileChangeNode.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ export class RemoteFileChangeNode extends TreeNode implements vscode.TreeItem {
8989
) {
9090
super();
9191
const viewed = this.pullRequest.fileChangeViewedState[fileName] ?? ViewedState.UNVIEWED;
92-
this.contextValue = `filechange:${GitChangeType[status]}:${
93-
viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
94-
}`;
92+
this.contextValue = `filechange:${GitChangeType[status]}:${viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
93+
}`;
9594
this.label = path.basename(fileName);
96-
this.description = path.relative('.', path.dirname(fileName));
95+
this.description = vscode.workspace.asRelativePath(path.dirname(fileName), false);
96+
if (this.description === '.') {
97+
this.description = '';
98+
}
9799
this.iconPath = vscode.ThemeIcon.File;
98100
this.resourceUri = toResourceUri(vscode.Uri.parse(this.blobUrl), pullRequest.number, fileName, status);
99101
this.updateViewed(viewed);
@@ -120,9 +122,8 @@ export class RemoteFileChangeNode extends TreeNode implements vscode.TreeItem {
120122
}
121123

122124
this._viewed = viewed;
123-
this.contextValue = `filechange:${GitChangeType[this.status]}:${
124-
viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
125-
}`;
125+
this.contextValue = `filechange:${GitChangeType[this.status]}:${viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
126+
}`;
126127
FileViewedDecorationProvider.updateFileViewedState(
127128
this.resourceUri,
128129
this.pullRequest.number,
@@ -169,11 +170,13 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
169170
) {
170171
super();
171172
const viewed = this.pullRequest.fileChangeViewedState[fileName] ?? ViewedState.UNVIEWED;
172-
this.contextValue = `filechange:${GitChangeType[status]}:${
173-
viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
174-
}`;
173+
this.contextValue = `filechange:${GitChangeType[status]}:${viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
174+
}`;
175175
this.label = path.basename(fileName);
176-
this.description = path.relative('.', path.dirname(fileName));
176+
this.description = vscode.workspace.asRelativePath(path.dirname(fileName), false);
177+
if (this.description === '.') {
178+
this.description = '';
179+
}
177180
this.iconPath = vscode.ThemeIcon.File;
178181
this.opts = {
179182
preserveFocus: true,
@@ -212,9 +215,8 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
212215
}
213216

214217
this._viewed = viewed;
215-
this.contextValue = `filechange:${GitChangeType[this.status]}:${
216-
viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
217-
}`;
218+
this.contextValue = `filechange:${GitChangeType[this.status]}:${viewed === ViewedState.VIEWED ? 'viewed' : 'unviewed'
219+
}`;
218220
FileViewedDecorationProvider.updateFileViewedState(
219221
this.resourceUri,
220222
this.pullRequest.number,

0 commit comments

Comments
 (0)