Skip to content

Commit b6a8c1c

Browse files
committed
fix(oxlint/lsp): clear disable directive entries for file on error (#18501)
When the file errors on tsgolint, we should remove the disable directives entries too (already doing in at the end of appending the diagnostics). Or else the next successful lint could have invalid spans too :)
1 parent 2065f31 commit b6a8c1c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apps/oxlint/src/lsp/server_linter.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,18 @@ impl ServerLinter {
702702
let mut fs = LspFileSystem::default();
703703
fs.add_file(path.to_path_buf(), Arc::from(source_text));
704704

705-
let mut messages: Vec<DiagnosticReport> = self
706-
.runner
707-
.run_source(&[Arc::from(path.as_os_str())], &fs)?
708-
.into_iter()
709-
.map(|message| message_to_lsp_diagnostic(message, uri, source_text, rope))
710-
.collect();
705+
let mut messages: Vec<DiagnosticReport> =
706+
match self.runner.run_source(&[Arc::from(path.as_os_str())], &fs) {
707+
Ok(results) => results
708+
.into_iter()
709+
.map(|message| message_to_lsp_diagnostic(message, uri, source_text, rope))
710+
.collect(),
711+
Err(e) => {
712+
// clear disable directives on error to prevent stale directives
713+
self.runner.directives_coordinator().remove(path);
714+
return Err(e);
715+
}
716+
};
711717

712718
messages.append(&mut generate_inverted_diagnostics(&messages, uri));
713719

0 commit comments

Comments
 (0)