fix diagnostics for deleted files

This commit is contained in:
Kujtim Hoxha
2025-04-28 19:37:42 +02:00
parent b3c0285db3
commit 2941137416
2 changed files with 14 additions and 5 deletions

View File

@@ -389,7 +389,7 @@ func (c *Client) openKeyConfigFiles(ctx context.Context) {
filepath.Join(workDir, "package.json"),
filepath.Join(workDir, "jsconfig.json"),
}
// Also find and open a few TypeScript files to help the server initialize
c.openTypeScriptFiles(ctx, workDir)
case ServerTypeGo:
@@ -547,12 +547,12 @@ func (c *Client) openTypeScriptFiles(ctx context.Context, workDir string) {
// shouldSkipDir returns true if the directory should be skipped during file search
func shouldSkipDir(path string) bool {
dirName := filepath.Base(path)
// Skip hidden directories
if strings.HasPrefix(dirName, ".") {
return true
}
// Skip common directories that won't contain relevant source files
skipDirs := map[string]bool{
"node_modules": true,
@@ -562,7 +562,7 @@ func shouldSkipDir(path string) bool {
"vendor": true,
"target": true,
}
return skipDirs[dirName]
}
@@ -776,3 +776,10 @@ func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]
return diagnostics, nil
}
// ClearDiagnosticsForURI removes diagnostics for a specific URI from the cache
func (c *Client) ClearDiagnosticsForURI(uri protocol.DocumentUri) {
c.diagnosticsMu.Lock()
defer c.diagnosticsMu.Unlock()
delete(c.diagnostics, uri)
}