Skip to content

Commit a2f03bf

Browse files
committed
Expand reference matching for positions to include target definition URIs
- when clicking on symbol -> find references, we have to be in a file it is defined. expected bahavior is that we can be in any file it is used └── apps └── editor └── src └── commands └── select-referencing-files-commands ├── index.ts ├── select-referencing-files-commands.ts └── utils ├── get-referencing-files-for-position.ts ├── get-referencing-files-for-uris.ts └── prompt-for-referencing-files.ts
1 parent 7c6af3a commit a2f03bf

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎apps/editor/src/commands/select-referencing-files-commands/select-referencing-files-commands.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,26 @@ export const select_referencing_files_commands = (
121121
}
122122

123123
const ignore_paths: string[] = []
124+
const target_uris: string[] = [target_uri!.toString()]
124125

125126
if (definitions) {
126127
for (const d of definitions) {
127128
const uri = d.uri || d.targetUri
128-
if (uri && uri.fsPath == target_uri!.fsPath) {
129-
if (!ignore_paths.includes(target_uri!.fsPath)) {
130-
ignore_paths.push(target_uri!.fsPath)
129+
if (uri) {
130+
target_uris.push(uri.toString())
131+
if (!ignore_paths.includes(uri.fsPath)) {
132+
ignore_paths.push(uri.fsPath)
131133
}
132134
}
133135
}
134136
}
135137

136138
return await get_referencing_files_for_position({
137-
uri: target_uri,
139+
uri: target_uri!,
138140
position: target_position,
139141
workspace_provider,
140-
ignore_paths
142+
ignore_paths,
143+
target_uris
141144
})
142145
}
143146
)

‎apps/editor/src/commands/select-referencing-files-commands/utils/get-referencing-files-for-position.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const get_referencing_files_for_position = async (params: {
77
position: vscode.Position
88
workspace_provider: WorkspaceProvider
99
ignore_paths: string[]
10+
target_uris: string[]
1011
}): Promise<{ file_path: string; range: vscode.Range }[]> => {
1112
let locations = await vscode.commands.executeCommand<vscode.Location[]>(
1213
'vscode.executeReferenceProvider',
@@ -48,7 +49,7 @@ export const get_referencing_files_for_position = async (params: {
4849
cached_imports.set(file_path, imports)
4950
}
5051

51-
if (imports.includes(params.uri.toString())) {
52+
if (params.target_uris.some((u) => imports.includes(u))) {
5253
file_map.set(file_path, loc.range)
5354
}
5455
}

0 commit comments

Comments
 (0)