don't look for imports outside workspace

This commit is contained in:
Dallin Romney 2025-03-27 13:34:37 -07:00
parent ae9c97ca67
commit 533b93d9ef

View file

@ -5,6 +5,7 @@ import {
getParserForFile,
getQueryForFile,
} from "../../util/treeSitter";
import { findUriInDirs } from "../../util/uri";
interface FileInfo {
imports: { [key: string]: RangeInFileWithContents[] };
@ -44,7 +45,15 @@ export class ImportDefinitionsService {
let fileContents: string | undefined = undefined;
try {
fileContents = await this.ide.readFile(filepath);
const { foundInDir } = findUriInDirs(
filepath,
await this.ide.getWorkspaceDirs(),
);
if (!foundInDir) {
return null;
} else {
fileContents = await this.ide.readFile(filepath);
}
} catch (err) {
// File removed
return null;