mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-21 05:52:35 +08:00
fix(vscode): skip non-file URIs in ImportDefinitionsService parser lookup (#7239)
VS Code output panel URIs (e.g. output:tasks) were being passed to getParserForFile, causing TypeError when tree-sitter Parser failed to load. Add early-return for non-file URI schemes and a defensive null check on the Parser export.
This commit is contained in:
+6
@@ -33,6 +33,12 @@ export class ImportDefinitionsService {
|
||||
return null
|
||||
}
|
||||
|
||||
// Skip non-file URIs (e.g. output:tasks, vscode:, untitled:) — these are
|
||||
// VS Code virtual documents that have no parseable source.
|
||||
if (/^[a-zA-Z][\w+.-]*:/.test(filepath) && !filepath.startsWith("file:") && !filepath.startsWith("/")) {
|
||||
return null
|
||||
}
|
||||
|
||||
const parser = await getParserForFile(filepath)
|
||||
if (!parser) {
|
||||
return {
|
||||
|
||||
@@ -126,6 +126,9 @@ export async function getParserForFile(filepath: string) {
|
||||
try {
|
||||
// Dynamically import Parser to avoid issues with WASM loading
|
||||
const { Parser } = require("web-tree-sitter")
|
||||
if (!Parser) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
await Parser.init()
|
||||
const parser = new Parser()
|
||||
|
||||
Reference in New Issue
Block a user