Skip to content

Commit 736739a

Browse files
committed
implement cleaning of diagnostics
1 parent b27fb0f commit 736739a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: handler/handler.go

+17
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,23 @@ func (handler *InoHandler) FromClangd(ctx context.Context, connection *jsonrpc2.
929929
// we should transform back N diagnostics of sketch.cpp.ino into
930930
// their .ino counter parts (that may span over multiple files...)
931931

932+
// Remove diagnostics from all .ino if there are no errors coming from clang
933+
if len(p.Diagnostics) == 0 {
934+
// XXX: Optimize this to publish "empty diagnostics" only to .ino that are
935+
// currently showing previous diagnostics.
936+
937+
for sourceURI := range handler.trackedFiles {
938+
msg := lsp.PublishDiagnosticsParams{
939+
URI: sourceURI,
940+
Diagnostics: []lsp.Diagnostic{},
941+
}
942+
if err := handler.StdioConn.Notify(ctx, "textDocument/publishDiagnostics", msg); err != nil {
943+
return nil, err
944+
}
945+
}
946+
return nil, nil
947+
}
948+
932949
convertedDiagnostics := map[string][]lsp.Diagnostic{}
933950
for _, cppDiag := range p.Diagnostics {
934951
inoSource, inoRange := handler.sketchMapper.CppToInoRange(cppDiag.Range)

0 commit comments

Comments
 (0)