Skip to content

Commit 1b44cc7

Browse files
committed
Fix error when accessing current file path
1 parent 9e561e5 commit 1b44cc7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/extension.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ function getGitHubLink(cb, fileFsPath, line) {
7070
branch = 'master';
7171

7272
projectName = parsedUri.substring(parsedUri.lastIndexOf("/") + 1, parsedUri.length);
73+
subdir = fileFsPath ? fileFsPath.substring(workspace.rootPath.length).replace(/\"/g, "") : undefined;
7374

74-
if (repoDir === cwd) {
75-
// The workspace directory is the git repo folder
76-
subdir = fileFsPath ? fileFsPath.substring(workspace.rootPath.length).replace(/\"/g, "") : undefined;
77-
} else {
75+
if (repoDir !== cwd) {
7876
// The workspace directory is a subdirectory of the git repo folder so we need to prepend the the nested path
7977
var repoRelativePath = cwd.replace(repoDir, "/");
80-
subdir = repoRelativePath + editor.document.uri.fsPath.substring(workspace.rootPath.length).replace(/\"/g, "");
81-
}
78+
subdir = repoRelativePath + subdir;
79+
}
8280

8381
if (parsedUri.startsWith(scUrls.github)) {
8482
gitLink = formGitHubLink(parsedUri, branch, subdir, line);

0 commit comments

Comments
 (0)