From ef456a1182012b266613fd0fbe03f8527719687c Mon Sep 17 00:00:00 2001 From: dkja Date: Fri, 8 Oct 2021 13:48:13 +0200 Subject: [PATCH] Add escape characters to current path - Issue #93 --- src/extension.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 2ffd25f..7920bd4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -273,7 +273,8 @@ export function currentEditorPathOption( if (!currentFileRoot) return; - const rootMatcher = new RegExp(`^${currentFileRoot.rootPath}`); + const rootPath = currentFileRoot.rootPath.replace(/[\/.*+?^${}()|[\]\\]/g, '\\$&'); + const rootMatcher = new RegExp(rootPath); let relativeCurrentFilePath = currentFilePath.replace(rootMatcher, ''); relativeCurrentFilePath =