Skip to content

Commit 3a5f466

Browse files
authored
Fix LSP to ignore excluded workspace files (#4239)
1 parent 2ef6d9e commit 3a5f466

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

private/buf/buflsp/file.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ func (f *file) RefreshWorkspace(ctx context.Context) {
210210
//
211211
// This operation requires a workspace.
212212
func (f *file) RefreshIR(ctx context.Context) {
213+
if f.objectInfo == nil {
214+
// This can happen if the file that is opened is excluded from the workspace through
215+
// includes/excludes in the build. In those cases, we ignore the file, the same way
216+
// the rest of our tools would.
217+
// In the future, we may want to rework this behavior in the LSP.
218+
return
219+
}
220+
213221
f.lsp.logger.Info(
214222
"parsing IR for file",
215223
slog.String("uri", string(f.uri)),

0 commit comments

Comments
 (0)