Skip to content

Commit

Permalink
Merge pull request #38 from bjrmatos/fix/37-improve-multiroot-support
Browse files Browse the repository at this point in the history
fix error when active text editor does not belong to any of the workspace folders of a multiroot workspace
  • Loading branch information
manifestinteractive authored Aug 21, 2022
2 parents 7492e39 + d44ffc2 commit cc0dec5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extension/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const getWorkspace = (context) => {
const relative = path.relative(wsFolder.uri.fsPath, vscode.window.activeTextEditor.document.uri.path)
return relative && !relative.startsWith('..') && !path.isAbsolute(relative)
})

// The file that is active does not belong to any of the workspace folders, so let's use the first workspace
if (!root) {
root = vscode.workspace.workspaceFolders[0]
}

workspace = root && root.uri ? root.uri.fsPath : null
} else {
// No file was open, so just grab the first available workspace
Expand Down

0 comments on commit cc0dec5

Please sign in to comment.