Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcy committed Oct 11, 2024
1 parent c4753b1 commit 1cb4c7e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions private/buf/buflsp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,11 @@ func (f *file) RefreshAST(ctx context.Context) bool {
func (f *file) PublishDiagnostics(ctx context.Context) {
defer slogext.DebugProfile(f.lsp.logger, slog.String("uri", string(f.uri)))()

// NOTE: We need to avoid sending a JSON null here, so we replace it with
// a non-nil empty slice when the diagnostics slice is nil.
diagnostics := f.diagnostics
if f.diagnostics == nil {
return
diagnostics = []protocol.Diagnostic{}
}

// Publish the diagnostics. This error is automatically logged by the LSP framework.
Expand All @@ -244,7 +247,7 @@ func (f *file) PublishDiagnostics(ctx context.Context) {
// NOTE: For some reason, Version is int32 in the document struct, but uint32 here.
// This seems like a bug in the LSP protocol package.
Version: uint32(f.version),
Diagnostics: f.diagnostics,
Diagnostics: diagnostics,
})
}

Expand Down

0 comments on commit 1cb4c7e

Please sign in to comment.