Skip to content

Commit e8d12c9

Browse files
authored
Handle Windows paths in git: URI construction (#6)
Alternative formulations that don't use gitApi.toGitUri are possible: vscode.Uri.from({ …, path: "/" + path, … }) vscode.Uri.from({ …, path: vscode.Uri.file(path).path, … }) vscode.Uri.file(path).with({ scheme: …, query: … }) The first alternative works, but mixes forward- and back-slashes (the incoming path has backslashes). The last two alternatives should be equivalent and give the same result as the version in this commit. All of them convert the directory separators to forward slashes, so the final URI looks like (e.g.) git:///c%3A/Users/me/Documents/…?… Note: The path property in the encoded query component seems like it must use backslashes on Windows. toGitUri uses fsPath for the encoded path property. Also, I got a different failure opening the vscode.diff link when I tried using slashes in the query's path property. toGitUrl: https://github.com/microsoft/vscode/blob/65a6a2f783dbc87fb3b1408c6a9b3e8d455a60a2/extensions/git/src/uri.ts#L32
1 parent 8d6f0d9 commit e8d12c9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ function buildHoverMessage(info: CommitInfo) {
500500
}
501501

502502
function gitUri(ref: Sha, path: string) {
503-
return vscode.Uri.from({ scheme: "git", path, query: JSON.stringify({ ref, path }) });
503+
return gitApi.toGitUri(vscode.Uri.file(path), ref)
504504
}
505505

506506
function getRepo(uri: vscode.Uri) {

0 commit comments

Comments
 (0)