@@ -961,10 +961,20 @@ func (ls *INOLanguageServer) TextDocumentDidOpenNotifFromIDE(logger jsonrpc.Func
961
961
ls .writeLock (logger , true )
962
962
defer ls .writeUnlock (logger )
963
963
964
- ls .triggerRebuild ()
964
+ ideTextDocItem := ideParam .TextDocument
965
+ clangURI , _ , err := ls .ide2ClangDocumentURI (logger , ideTextDocItem .URI )
966
+ if err != nil {
967
+ logger .Logf ("Error: %s" , err )
968
+ return
969
+ }
970
+
971
+ if ls .ideURIIsPartOfTheSketch (ideTextDocItem .URI ) {
972
+ if ! clangURI .AsPath ().Exist () {
973
+ ls .triggerRebuildAndWait (logger )
974
+ }
975
+ }
965
976
966
977
// Add the TextDocumentItem in the tracked files list
967
- ideTextDocItem := ideParam .TextDocument
968
978
ls .trackedIdeDocs [ideTextDocItem .URI .AsPath ().String ()] = ideTextDocItem
969
979
970
980
// If we are tracking a .ino...
@@ -979,11 +989,6 @@ func (ls *INOLanguageServer) TextDocumentDidOpenNotifFromIDE(logger jsonrpc.Func
979
989
}
980
990
}
981
991
982
- clangURI , _ , err := ls .ide2ClangDocumentURI (logger , ideTextDocItem .URI )
983
- if err != nil {
984
- logger .Logf ("Error: %s" , err )
985
- return
986
- }
987
992
clangTextDocItem := lsp.TextDocumentItem {
988
993
URI : clangURI ,
989
994
}
@@ -1198,6 +1203,30 @@ func (ls *INOLanguageServer) PublishDiagnosticsNotifFromClangd(logger jsonrpc.Fu
1198
1203
}
1199
1204
}
1200
1205
1206
+ // Try to filter as much bogus errors as possible (due to wrong clang "driver" or missing
1207
+ // support for specific embedded CPU architecture).
1208
+ for _ , ideParams := range allIdeParams {
1209
+ n := 0
1210
+ for _ , ideDiag := range ideParams .Diagnostics {
1211
+ var code string
1212
+ _ = json .Unmarshal (ideDiag .Code , & code )
1213
+ switch code {
1214
+ case "" :
1215
+ // Filter unkown non-string codes
1216
+ case "drv_unknown_argument_with_suggestion" :
1217
+ // Skip errors like: "Unknown argument '-mlongcalls'; did you mean '-mlong-calls'?"
1218
+ case "drv_unknown_argument" :
1219
+ // Skip errors like: "Unknown argument: '-mtext-section-literals'"
1220
+ default :
1221
+ ideParams .Diagnostics [n ] = ideDiag
1222
+ n ++
1223
+ continue
1224
+ }
1225
+ logger .Logf ("filtered out diagnostic with error-code: %s" , ideDiag .Code )
1226
+ }
1227
+ ideParams .Diagnostics = ideParams .Diagnostics [:n ]
1228
+ }
1229
+
1201
1230
// Push back to IDE the converted diagnostics
1202
1231
logger .Logf ("diagnostics to IDE:" )
1203
1232
for _ , ideParams := range allIdeParams {
0 commit comments