Skip to content

Commit

Permalink
make the lsp always publish diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
mcy committed Oct 11, 2024
1 parent 71e170e commit c4753b1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions private/buf/buflsp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (f *file) Refresh(ctx context.Context) {
progress.Begin(ctx, "Indexing")

progress.Report(ctx, "Parsing AST", 1.0/6)
hasReport := f.RefreshAST(ctx)
f.RefreshAST(ctx)

progress.Report(ctx, "Indexing Imports", 2.0/6)
f.IndexImports(ctx)
Expand All @@ -179,15 +179,17 @@ func (f *file) Refresh(ctx context.Context) {

progress.Report(ctx, "Linking Descriptors", 4.0/6)
f.BuildImage(ctx)
hasReport = f.RunLints(ctx) || hasReport // Avoid short-circuit here.
f.RunLints(ctx)

progress.Report(ctx, "Indexing Symbols", 5.0/6)
f.IndexSymbols(ctx)

progress.Done(ctx)
if hasReport {
f.PublishDiagnostics(ctx)
}

// NOTE: Diagnostics are published unconditionally. This is necessary even
// if we have zero diagnostics, so that the client correctly ticks over from
// n > 0 diagnostics to 0 diagnostics.
f.PublishDiagnostics(ctx)
}

// RefreshAST reparses the file and generates diagnostics if necessary.
Expand Down

0 comments on commit c4753b1

Please sign in to comment.