Merge pull request #2633 from kylewlacy/fix-workspace-check

Fix false positives when checking if a file is in a workspace
This commit is contained in:
Patrick Erichsen 2024-10-24 10:48:10 -07:00 • committed by GitHub
commit 6a9b7615e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -268,7 +268,10 @@ export class CompletionProvider {
const workspaceDirs = await this.ide.getWorkspaceDirs();
let filepath = input.filepath;
for (const workspaceDir of workspaceDirs) {
if (filepath.startsWith(workspaceDir)) {
const relativePath = path.relative(workspaceDir, filepath);
const relativePathBase = relativePath.split(path.sep).at(0);
const isInWorkspace = !path.isAbsolute(relativePath) && relativePathBase !== "..";
if (isInWorkspace) {
filepath = path.relative(workspaceDir, filepath);
break;
}