Skip to content

Commit 8f8dce4

Browse files
committed
Use first definition's URI and range start as search location when finding referencing files
- clicking on a local import alias e.g. 'UiStatusBar' should list references of StatusBar └── apps └── editor └── src ├── commands │ ├── select-definition-file-command.ts │ └── 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 └── views └── prompt └── frontend └── Main └── MainView └── MainView.tsx
1 parent ede4195 commit 8f8dce4

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ export const select_referencing_files_commands = (
125125
const ignore_paths: string[] = []
126126
const target_uris: string[] = [target_uri!.toString()]
127127

128+
let search_uri = target_uri!
129+
let search_position = target_position!
130+
128131
if (definitions) {
129132
for (const d of definitions) {
130133
const uri = d.uri || d.targetUri
@@ -135,11 +138,25 @@ export const select_referencing_files_commands = (
135138
}
136139
}
137140
}
141+
142+
if (definitions.length > 0) {
143+
const first_def = definitions[0]
144+
const def_uri = first_def.uri || first_def.targetUri
145+
const def_range =
146+
first_def.targetSelectionRange ||
147+
first_def.targetRange ||
148+
first_def.range
149+
150+
if (def_uri && def_range) {
151+
search_uri = def_uri
152+
search_position = def_range.start
153+
}
154+
}
138155
}
139156

140157
return await get_referencing_files_for_position({
141-
uri: target_uri!,
142-
position: target_position,
158+
uri: search_uri,
159+
position: search_position,
143160
workspace_provider,
144161
ignore_paths,
145162
target_uris

0 commit comments

Comments
 (0)