From 51b40423f49e67601fb1316dcd74ca5273012178 Mon Sep 17 00:00:00 2001 From: Naman Sood Date: Thu, 21 Sep 2023 11:27:00 -0400 Subject: [PATCH] Node Explorer: accept subdirectories of ~ for root directory (#230) Fixes #200. --------- Signed-off-by: Naman Sood --- src/extension.ts | 2 +- src/node-explorer-provider.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 3d1b805..ac1daee 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -168,7 +168,7 @@ export async function activate(context: vscode.ExtensionContext) { return; } - if (!path.isAbsolute(dir) && dir !== '~') { + if (!path.isAbsolute(dir) && dir !== '~' && !dir.startsWith('~/')) { vscode.window.showErrorMessage(`${dir} is an invalid absolute path`); return; } diff --git a/src/node-explorer-provider.ts b/src/node-explorer-provider.ts index 00f452a..7a357bd 100644 --- a/src/node-explorer-provider.ts +++ b/src/node-explorer-provider.ts @@ -105,6 +105,9 @@ export class NodeExplorerProvider const homeDir = await this.fsProvider.getHomeDirectory(element.Address); if (rootDir && rootDir !== '~') { + if (rootDir.startsWith('~/')) { + rootDir = `${homeDir}/${rootDir.slice(2)}`; + } dirDesc = trimPathPrefix(rootDir, homeDir); } else { rootDir = homeDir;