@@ -2150,12 +2150,23 @@ func (l *LanguageServer) loadWorkspaceContents(ctx context.Context, newOnly bool
21502150 return nil
21512151 }
21522152
2153- if _ , err = updateParse (ctx , l .parseOpts (fileURI , l .builtinsForCurrentCapabilities ())); err != nil {
2153+ parseSuccess , err := updateParse (ctx , l .parseOpts (fileURI , l .builtinsForCurrentCapabilities ()))
2154+ if err != nil {
21542155 failed = append (failed , fileLoadFailure {URI : fileURI , Error : fmt .Errorf ("failed to update parse: %w" , err )})
21552156
21562157 return nil // continue processing other files
21572158 }
21582159
2160+ if parseSuccess {
2161+ l .testLocationJobs <- lintFileJob {Reason : "server initialized" , URI : fileURI }
2162+ } else {
2163+ // this is covering the case where the client starts and the state
2164+ // is different (the client remembers test locations and state).
2165+ if err := l .sendTestLocations (ctx , fileURI , []any {}); err != nil {
2166+ l .log .Message ("failed to send empty test locations after parse failure: %s" , err )
2167+ }
2168+ }
2169+
21592170 changedOrNewURIs = append (changedOrNewURIs , fileURI )
21602171
21612172 return nil
@@ -2221,6 +2232,12 @@ func (l *LanguageServer) handleWorkspaceDidChangeWatchedFiles(
22212232}
22222233
22232234func (l * LanguageServer ) sendFileDiagnostics (ctx context.Context , fileURI string ) {
2235+ if l .conn == nil {
2236+ l .log .Debug ("sendFileDiagnostics called with no connection: %s" , fileURI )
2237+
2238+ return
2239+ }
2240+
22242241 // first, set the diagnostics for the file to the current parse errors
22252242 fileDiags , _ := l .cache .GetParseErrors (fileURI )
22262243 if len (fileDiags ) == 0 {
0 commit comments