Skip to content

Commit

Permalink
feat: clear diagnostics after closing file
Browse files Browse the repository at this point in the history
  • Loading branch information
seven332 committed Nov 12, 2023
1 parent 53af1c0 commit 1481355
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ documents.onDidChangeContent((event) => {
})

documents.onDidClose((event) => {
server?.close(event.document.uri)
const diagnostics = server?.close(event.document.uri)
if (diagnostics) {
connection.sendDiagnostics({
uri: event.document.uri,
diagnostics,
})
}
})

connection.onDocumentSymbol((params) => {
Expand Down
3 changes: 2 additions & 1 deletion src/sksl-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class SkSLServer {
)
}

public close(uri: string) {
public close(uri: string): ls.Diagnostic[] | undefined {
const file = URI.parse(uri).fsPath
const uris = this.files.get(file)
if (uris) {
Expand All @@ -55,6 +55,7 @@ export class SkSLServer {
// Delete document
this.documents.delete(file)
}
return []
}

public getSymbol(uri: string): ls.DocumentSymbol[] {
Expand Down

0 comments on commit 1481355

Please sign in to comment.