Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2150,12 +2150,23 @@ func (l *LanguageServer) loadWorkspaceContents(ctx context.Context, newOnly bool
return nil
}

if _, err = updateParse(ctx, l.parseOpts(fileURI, l.builtinsForCurrentCapabilities())); err != nil {
parseSuccess, err := updateParse(ctx, l.parseOpts(fileURI, l.builtinsForCurrentCapabilities()))
if err != nil {
failed = append(failed, fileLoadFailure{URI: fileURI, Error: fmt.Errorf("failed to update parse: %w", err)})

return nil // continue processing other files
}

if parseSuccess {
l.testLocationJobs <- lintFileJob{Reason: "server initialized", URI: fileURI}
} else {
// this is covering the case where the client starts and the state
// is different (the client remembers test locations and state).
if err := l.sendTestLocations(ctx, fileURI, []any{}); err != nil {
l.log.Message("failed to send empty test locations after parse failure: %s", err)
}
}

changedOrNewURIs = append(changedOrNewURIs, fileURI)

return nil
Expand Down Expand Up @@ -2221,6 +2232,12 @@ func (l *LanguageServer) handleWorkspaceDidChangeWatchedFiles(
}

func (l *LanguageServer) sendFileDiagnostics(ctx context.Context, fileURI string) {
if l.conn == nil {
l.log.Debug("sendFileDiagnostics called with no connection: %s", fileURI)

return
}

// first, set the diagnostics for the file to the current parse errors
fileDiags, _ := l.cache.GetParseErrors(fileURI)
if len(fileDiags) == 0 {
Expand Down
6 changes: 6 additions & 0 deletions internal/lsp/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func (l *LanguageServer) processTestLocationsUpdate(ctx context.Context, fileURI
}

func (l *LanguageServer) sendTestLocations(ctx context.Context, fileURI string, locations any) error {
if l.conn == nil {
l.log.Debug("sendTestLocations called with no connection: %s", fileURI)

return nil
}

params := map[string]any{
"uri": fileURI,
"locations": locations,
Expand Down
Loading