Skip to content

Commit 1913b49

Browse files
fix: Error diagnostics must not be marked as "OK"
1 parent 5cce73b commit 1913b49

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Diagnostic.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ export const generatePackagesDiagnostics = async (
272272
packageDiagnostic
273273
)
274274
}
275+
276+
if (packageDiagnostic.severity === DiagnosticSeverity.Error) {
277+
return documentDecorations?.clearLine(packageInfo.getLine())
278+
}
275279
}
276280

277281
documentDecorations?.setCheckedMessage(packageInfo.getLine())

src/DocumentDecoration.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ export class DocumentDecoration {
158158
this.render()
159159
}
160160

161+
public clearLine(line: number): void {
162+
DocumentDecorationManager.fromDocument(this.document).layers.forEach(
163+
(decoration) => decoration.lines.delete(line)
164+
)
165+
166+
this.render()
167+
}
168+
161169
public setCheckedMessage(line: number): void {
162170
this.setLine(line, [
163171
new Message(

src/extension.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe("package diagnostics", () => {
277277
})
278278

279279
expect(diagnostics[0]?.message).toContain("Invalid package version")
280-
expect(decorations[0]).toStrictEqual([Icons.CHECKED])
280+
expect(decorations).toStrictEqual([])
281281
})
282282

283283
it("decorations disabled", async () => {
@@ -617,7 +617,7 @@ describe("code coverage", () => {
617617
)?.[1](document)
618618

619619
expect(diagnostics).toHaveLength(1)
620-
expect(decorations[0]).toStrictEqual([Icons.CHECKED])
620+
expect(decorations).toStrictEqual([])
621621
})
622622

623623
it("decoration re-flush layers", async () => {

0 commit comments

Comments
 (0)