From 48c2debd830235aa74575a4e69b15d1289c49b32 Mon Sep 17 00:00:00 2001 From: Sean Lee Date: Thu, 12 May 2022 11:29:51 -0700 Subject: [PATCH] Pass the correct fiile path to getOwner This fixes an issue where the path passed to codeowners getOwner did not match up with the detected CODEOWNERS path. --- extension.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/extension.js b/extension.js index ef2b2a1..62db59e 100644 --- a/extension.js +++ b/extension.js @@ -10,22 +10,19 @@ const getOwners = () => { return []; } - const { fileName, uri } = vscode.window.activeTextEditor.document; - - const { - uri: { fsPath: workspacePath } - } = vscode.workspace.getWorkspaceFolder(uri); + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) return null; + const { fileName } = activeTextEditor.document; let folder; try { - folder = new Codeowners(workspacePath); + folder = new Codeowners(path.dirname(path.resolve(fileName))); } catch { // no CODEOWNERS file return null; } - const file = fileName.split(`${workspacePath}${path.sep}`)[1]; - + const file = path.relative(folder.codeownersDirectory, fileName) return folder.getOwner(file); };