Skip to content

Commit 34d693e

Browse files
committed
Restrict search in results to selected items
- add missing translations to [Fragment]
1 parent 942dacc commit 34d693e

9 files changed

Lines changed: 57 additions & 40 deletions

File tree

‎apps/editor/src/commands/search-files-commands/utils/prompt-for-provided-results.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const prompt_for_provided_results = async (params: {
3434
}
3535
const search_in_results_button = {
3636
iconPath: new vscode.ThemeIcon('search'),
37-
tooltip: t('common.search-in-results')
37+
tooltip: t('common.search-in-selected-results')
3838
}
3939

4040
const is_multi_root =
@@ -111,12 +111,13 @@ export const prompt_for_provided_results = async (params: {
111111
quick_pick.onDidTriggerButton((button) => {
112112
if (button === search_in_results_button) {
113113
is_accepted = true
114+
const selected = quick_pick.selectedItems
115+
.map((item) => item.file_path)
116+
.filter((p): p is string => p !== undefined)
114117
resolve({
115118
action: 'search-in-results',
116-
matched_paths: params.files.map((f) => f.path),
117-
selected_paths: quick_pick.selectedItems
118-
.map((item) => item.file_path)
119-
.filter((p): p is string => p !== undefined)
119+
matched_paths: selected,
120+
selected_paths: selected
120121
})
121122
quick_pick.hide()
122123
} else if (button === close_button) {

‎apps/editor/src/commands/select-clipboard-paths-command.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export const select_clipboard_paths_command = (
262262
}
263263
const search_button = {
264264
iconPath: new vscode.ThemeIcon('search'),
265-
tooltip: t('common.search-in-results')
265+
tooltip: t('common.search-in-selected-results')
266266
}
267267

268268
quick_pick.buttons = [
@@ -339,7 +339,8 @@ export const select_clipboard_paths_command = (
339339

340340
if (selected_items === 'search') {
341341
const search_result = await search_files({
342-
get_files: async () => absolute_paths,
342+
get_files: async () =>
343+
current_selected_items.map((i) => i.file_path),
343344
workspace_provider,
344345
extension_context,
345346
websocket_manager,

‎apps/editor/src/commands/select-files-of-commit-command.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export const select_files_of_commit_command = (
429429

430430
const search_button = {
431431
iconPath: new vscode.ThemeIcon('search'),
432-
tooltip: t('common.search-in-results')
432+
tooltip: t('common.search-in-selected-results')
433433
}
434434

435435
const close_button = {
@@ -445,6 +445,7 @@ export const select_files_of_commit_command = (
445445
quick_pick_files.ignoreFocusOut = true
446446

447447
let is_showing_folder_quick_pick = false
448+
let current_selected_items: any[] = []
448449

449450
const selected_files = await new Promise<
450451
any[] | 'back' | undefined | 'search'
@@ -460,6 +461,9 @@ export const select_files_of_commit_command = (
460461
quick_pick_files.hide()
461462
} else if (button === search_button) {
462463
is_resolved = true
464+
current_selected_items = [
465+
...quick_pick_files.selectedItems
466+
]
463467
resolve('search')
464468
quick_pick_files.hide()
465469
} else if (button === close_button) {
@@ -551,7 +555,7 @@ export const select_files_of_commit_command = (
551555
if (selected_files === 'search') {
552556
const search_result = await search_files({
553557
get_files: async () =>
554-
valid_files.map((f) => f.absolute_path),
558+
current_selected_items.map((i) => i.file_path),
555559
workspace_provider,
556560
extension_context,
557561
websocket_manager,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export const prompt_for_referencing_files = async (params: {
216216

217217
if (selected_items === 'search') {
218218
const search_result = await search_files({
219-
get_files: async () => matched_files.map((m) => m.file_path),
219+
get_files: async () => current_selected_items.map((i) => i.file_path),
220220
workspace_provider: params.workspace_provider,
221221
extension_context: params.extension_context,
222222
websocket_manager: params.websocket_manager,

‎apps/editor/src/commands/select-unstaged-files-command.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export const select_unstaged_files_command = (
149149

150150
const search_button = {
151151
iconPath: new vscode.ThemeIcon('search'),
152-
tooltip: t('common.search-in-results')
152+
tooltip: t('common.search-in-selected-results')
153153
}
154154
const close_button = {
155155
iconPath: new vscode.ThemeIcon('close'),
@@ -158,6 +158,10 @@ export const select_unstaged_files_command = (
158158

159159
quick_pick.buttons = [search_button, close_button]
160160

161+
let current_selected_items: readonly (vscode.QuickPickItem & {
162+
file_path: string
163+
})[] = []
164+
161165
const selected_items = await new Promise<
162166
| readonly (vscode.QuickPickItem & { file_path: string })[]
163167
| undefined
@@ -167,6 +171,7 @@ export const select_unstaged_files_command = (
167171

168172
quick_pick.onDidTriggerButton((button) => {
169173
if (button === search_button) {
174+
current_selected_items = [...quick_pick.selectedItems]
170175
resolve('search')
171176
quick_pick.hide()
172177
} else if (button === close_button) {
@@ -214,7 +219,8 @@ export const select_unstaged_files_command = (
214219

215220
if (selected_items === 'search') {
216221
const search_result = await search_files({
217-
get_files: async () => existing_unstaged_files,
222+
get_files: async () =>
223+
current_selected_items.map((i) => i.file_path),
218224
workspace_provider,
219225
extension_context,
220226
websocket_manager,

‎apps/editor/src/features/imported-files/utils/prompt-for-imported-files.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,11 @@ export const prompt_for_imported_files = async (params: {
435435
}
436436

437437
if (selected_items == 'search') {
438+
const selected_uris = current_selected_items
439+
.filter((i) => i.uri)
440+
.map((i) => i.uri!.fsPath)
438441
const search_result = await search_files({
439-
get_files: async () => shown_paths,
442+
get_files: async () => selected_uris,
440443
workspace_provider,
441444
extension_context,
442445
websocket_manager,

‎apps/editor/src/features/search-files/utils/prompt-for-intelligent-search-results.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const prompt_for_intelligent_search_results = async (params: {
6666
}
6767
const search_in_results_button = {
6868
iconPath: new vscode.ThemeIcon('search'),
69-
tooltip: t('common.search-in-results')
69+
tooltip: t('common.search-in-selected-results')
7070
}
7171

7272
const is_multi_root =
@@ -184,12 +184,13 @@ export const prompt_for_intelligent_search_results = async (params: {
184184
quick_pick.hide()
185185
} else if (button === search_in_results_button) {
186186
is_resolved = true
187+
const selected = quick_pick.selectedItems
188+
.map((item) => item.file_path)
189+
.filter((p): p is string => p !== undefined)
187190
resolve({
188191
action: 'search-in-results',
189-
matched_paths: [...unique_paths, ...unmatched_checked_files],
190-
selected_paths: quick_pick.selectedItems
191-
.map((item) => item.file_path)
192-
.filter((p): p is string => p !== undefined),
192+
matched_paths: selected,
193+
selected_paths: selected,
193194
unmatched_paths: unmatched_checked_files
194195
})
195196
quick_pick.hide()

‎apps/editor/src/features/search-files/utils/prompt-for-search-results.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const prompt_for_search_results = async (params: {
4343
}
4444
const search_in_results_button = {
4545
iconPath: new vscode.ThemeIcon('search'),
46-
tooltip: t('common.search-in-results')
46+
tooltip: t('common.search-in-selected-results')
4747
}
4848

4949
const currently_checked = params.workspace_provider.get_checked_files()
@@ -169,12 +169,13 @@ export const prompt_for_search_results = async (params: {
169169
quick_pick.hide()
170170
} else if (button === search_in_results_button) {
171171
is_accepted = true
172+
const selected = quick_pick.selectedItems
173+
.map((item) => item.file_path)
174+
.filter((p): p is string => p !== undefined)
172175
resolve({
173176
action: 'search-in-results',
174-
matched_paths: [...params.matched_files, ...unmatched_checked_files],
175-
selected_paths: quick_pick.selectedItems
176-
.map((item) => item.file_path)
177-
.filter((p): p is string => p !== undefined),
177+
matched_paths: selected,
178+
selected_paths: selected,
178179
unmatched_paths: unmatched_checked_files
179180
})
180181
quick_pick.hide()

‎apps/editor/src/i18n/translations/common.ts‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -341,23 +341,23 @@ export const translations = {
341341
hu: 'Törlés',
342342
bg: 'Изтриване'
343343
},
344-
'common.search-in-results': {
345-
en: 'Search in results',
346-
pl: 'Szukaj w wynikach',
347-
'zh-cn': '在结果中搜索',
348-
ja: '結果内を検索',
349-
'zh-tw': '在結果中搜尋',
350-
de: 'In den Ergebnissen suchen',
351-
es: 'Buscar en los resultados',
352-
fr: 'Rechercher dans les résultats',
353-
'pt-br': 'Pesquisar nos resultados',
354-
ru: 'Искать в результатах',
355-
ko: '결과에서 검색',
356-
it: 'Cerca nei risultati',
357-
tr: 'Sonuçlarda ara',
358-
cs: 'Hledat ve výsledcích',
359-
hu: 'Keresés az eredményekben',
360-
bg: 'Търсене в резултатите'
344+
'common.search-in-selected-results': {
345+
en: 'Search in selected results',
346+
pl: 'Szukaj w wybranych wynikach',
347+
'zh-cn': '在选中的结果中搜索',
348+
ja: '選択した結果内を検索',
349+
'zh-tw': '在選取的結果中搜尋',
350+
de: 'In ausgewählten Ergebnissen suchen',
351+
es: 'Buscar en los resultados seleccionados',
352+
fr: 'Rechercher dans les résultats sélectionnés',
353+
'pt-br': 'Pesquisar nos resultados selecionados',
354+
ru: 'Поиск в выбранных результатах',
355+
ko: '선택한 결과에서 검색',
356+
it: 'Cerca nei risultati selezionati',
357+
tr: 'Seçilen sonuçlarda ara',
358+
cs: 'Hledat ve vybraných výsledcích',
359+
hu: 'Keresés a kiválasztott eredményekben',
360+
bg: 'Търсене в избраните резултати'
361361
},
362362
'common.next': {
363363
en: 'Next',

0 commit comments

Comments
 (0)