Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lsp/base_service_client/base_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func EvaluateReferenced[T base](t T, ctx ctx, cap string, info []byte) (resp, er
for _, ref := range references {
// Look for things that are in the location loaded,
// Note may need to filter out vendor at some point
if !strings.Contains(ref.URI, sc.BaseConfig.WorkspaceFolders[0]) {
if len(sc.BaseConfig.WorkspaceFolders) > 0 && !strings.Contains(ref.URI, sc.BaseConfig.WorkspaceFolders[0]) {
continue
}
Comment on lines +68 to 70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Semantic change: empty WorkspaceFolders now processes all references.

The guard prevents the out-of-bounds panic, but when WorkspaceFolders is empty, the condition short-circuits to false, so the continue statement doesn't execute. This means all references will be processed rather than being filtered to the workspace.

Given the intent (per the comment above) is to filter references to the loaded location, consider returning early or explicitly handling the empty case:

+	if len(sc.BaseConfig.WorkspaceFolders) == 0 {
+		return resp{Matched: false}, nil
+	}
+
 	for _, s := range symbols {
 		references := sc.GetAllReferences(ctx, s.Location.Value.(protocol.Location))
 
 		breakEarly := false
 		for _, ref := range references {
 			// Look for things that are in the location loaded,
 			// Note may need to filter out vendor at some point
-			if len(sc.BaseConfig.WorkspaceFolders) > 0 && !strings.Contains(ref.URI, sc.BaseConfig.WorkspaceFolders[0]) {
+			if !strings.Contains(ref.URI, sc.BaseConfig.WorkspaceFolders[0]) {
 				continue
 			}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In lsp/base_service_client/base_capabilities.go around lines 68 to 70, the
current guard uses sc.BaseConfig.WorkspaceFolders[0] without explicitly handling
the empty-slice case which causes the condition to evaluate to false and thus
processes all references; update the code to explicitly handle
len(sc.BaseConfig.WorkspaceFolders) == 0 (either return early or skip processing
references by continuing) and only access WorkspaceFolders[0] after confirming
length > 0 so references are correctly filtered to the loaded workspace.


Expand Down
Loading