Skip to content

Commit 533b93d

Browse files
committed
don't look for imports outside workspace
1 parent ae9c97c commit 533b93d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/autocomplete/context/ImportDefinitionsService.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getParserForFile,
66
getQueryForFile,
77
} from "../../util/treeSitter";
8+
import { findUriInDirs } from "../../util/uri";
89

910
interface FileInfo {
1011
imports: { [key: string]: RangeInFileWithContents[] };
@@ -44,7 +45,15 @@ export class ImportDefinitionsService {
4445

4546
let fileContents: string | undefined = undefined;
4647
try {
47-
fileContents = await this.ide.readFile(filepath);
48+
const { foundInDir } = findUriInDirs(
49+
filepath,
50+
await this.ide.getWorkspaceDirs(),
51+
);
52+
if (!foundInDir) {
53+
return null;
54+
} else {
55+
fileContents = await this.ide.readFile(filepath);
56+
}
4857
} catch (err) {
4958
// File removed
5059
return null;

0 commit comments

Comments
 (0)