-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vls): should preserve error after editing file without error
- Loading branch information
Showing
6 changed files
with
105 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { NormalizedDiagnostic } from './logger' | ||
|
||
class FileDiagnosticCache { | ||
public diagnostics: NormalizedDiagnostic[] = [] | ||
|
||
public initWith(diagnostics: NormalizedDiagnostic[]) { | ||
diagnostics.forEach((d) => { | ||
this.diagnostics.push(d) | ||
}) | ||
} | ||
|
||
public getDiagnostics(fileName?: string) { | ||
if (fileName) { | ||
return this.diagnostics.filter((f) => f.id === fileName) | ||
} | ||
|
||
return this.diagnostics | ||
} | ||
|
||
public get lastDiagnostic() { | ||
return this.diagnostics[this.diagnostics.length - 1] | ||
} | ||
|
||
public setFile(fileName: string, next: NormalizedDiagnostic[] | null) { | ||
for (let i = 0; i < this.diagnostics.length; i++) { | ||
if (this.diagnostics[i].id === fileName) { | ||
this.diagnostics.splice(i, 1) | ||
i-- | ||
} | ||
} | ||
|
||
if (next?.length) { | ||
this.diagnostics.push(...next) | ||
} | ||
} | ||
} | ||
|
||
export { FileDiagnosticCache } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters