Skip to content

Commit 0233ed9

Browse files
authored
Check workspace folder with both original and real path (#827)
1 parent e467d38 commit 0233ed9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/session.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,21 @@ export async function getWebviewHtml(webview: Webview, file: string, title: stri
660660

661661
function isFromWorkspace(dir: string) {
662662
if (workspace.workspaceFolders === undefined) {
663-
const rel = path.relative(os.homedir(), dir);
663+
let rel = path.relative(os.homedir(), dir);
664+
if (rel === '') {
665+
return true;
666+
}
667+
rel = path.relative(fs.realpathSync(os.homedir()), dir);
664668
if (rel === '') {
665669
return true;
666670
}
667671
} else {
668672
for (const folder of workspace.workspaceFolders) {
669-
const rel = path.relative(folder.uri.fsPath, dir);
673+
let rel = path.relative(folder.uri.fsPath, dir);
674+
if (!rel.startsWith('..') && !path.isAbsolute(rel)) {
675+
return true;
676+
}
677+
rel = path.relative(fs.realpathSync(folder.uri.fsPath), dir);
670678
if (!rel.startsWith('..') && !path.isAbsolute(rel)) {
671679
return true;
672680
}

0 commit comments

Comments
 (0)