Commit fb9d0f4
authored
fix(language_server): don't resend diagnostic on save, when
Fixes an edge case introduced in #13332 where diagnostics disappear when
saving a file with `oxc.lint.run: "onType"` and `oxc.typeAware: false`.
## Problem
The logic from #13332 assumes `tsgolint` always exists when
`Run::OnType`:
```rust
(ServerLinterRun::OnSave, Run::OnType) => (false, true) // always run tsgolint
```
But when `type_aware: false`, there is no `tsgo_linter`, causing the
server to return empty diagnostics instead of None, which clears all
error highlights in VSCode.

## Solution
Check if `tsgo_linter` actually exists:
```rust
(ServerLinterRun::OnSave, Run::OnType) => {
let should_run_tsgo = self.tsgo_linter.as_ref().is_some();
(false, should_run_tsgo)
}
```
Now returns None when no linters should run, preserving existing
diagnostics.
**Test:** Added `test_lint_on_run_on_type_on_save_without_type_aware`
with fixturetypeAware is disabled and run is onType (#13604)1 parent 2f36350 commit fb9d0f4
File tree
3 files changed
+28
-3
lines changed- crates/oxc_language_server
- fixtures/linter/lint_on_run/on_type
- src
- linter
- snapshots
3 files changed
+28
-3
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
336 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
337 | 340 | | |
338 | 341 | | |
339 | 342 | | |
| |||
483 | 486 | | |
484 | 487 | | |
485 | 488 | | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
486 | 499 | | |
487 | 500 | | |
488 | 501 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments