Skip to content

Commit 8218a8d

Browse files
committed
Prevent search-in-results action when no files are selected by showing an informational message instead
- when no files are selected, 'search in results' should trigger appropriate info notification and don't let itself be used - add missing translations [Pasted text] └── apps └── editor └── src ├── commands │ └── search-files-commands │ ├── index.ts │ ├── search-files-commands.ts │ └── utils │ ├── get-target-folder-path.ts │ └── prompt-for-provided-results.ts ├── features │ └── search-files │ ├── index.ts │ ├── search-files.ts │ ├── search-modes │ │ ├── perform-intelligent-search-mode.ts │ │ ├── perform-keywords-search-mode.ts │ │ └── perform-phrase-search-mode.ts │ └── utils │ ├── analyze-files.ts │ ├── check-matches-condition.ts │ ├── create-search-regex.ts │ ├── group-quick-pick-items.ts │ ├── handle-parent-folder-result.ts │ ├── map-files-to-quick-pick-items.ts │ ├── prompt-for-config.ts │ ├── prompt-for-intelligent-search-results.ts │ ├── prompt-for-keywords-match-mode.ts │ ├── prompt-for-keywords-target.ts │ ├── prompt-for-search-mode.ts │ ├── prompt-for-search-results.ts │ ├── prompt-for-search-term.ts │ ├── prompt-for-shrink-mode.ts │ ├── search-files-by-intelligent.ts │ ├── search-files-by-keywords.ts │ └── search-files-by-phrase.ts └── i18n └── translations ├── commands │ └── search-files.ts └── features └── search-files.ts
1 parent 630a83b commit 8218a8d

4 files changed

Lines changed: 46 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,18 @@ export const prompt_for_provided_results = async (params: {
110110

111111
quick_pick.onDidTriggerButton((button) => {
112112
if (button === search_in_results_button) {
113-
is_accepted = true
114113
const selected = quick_pick.selectedItems
115114
.map((item) => item.file_path)
116115
.filter((p): p is string => p !== undefined)
116+
117+
if (selected.length == 0) {
118+
vscode.window.showInformationMessage(
119+
t('feature.search-files.info.no-files-selected')
120+
)
121+
return
122+
}
123+
124+
is_accepted = true
117125
resolve({
118126
action: 'search-in-results',
119127
matched_paths: selected,

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,18 @@ export const prompt_for_intelligent_search_results = async (params: {
183183
resolve('back')
184184
quick_pick.hide()
185185
} else if (button === search_in_results_button) {
186-
is_resolved = true
187186
const selected = quick_pick.selectedItems
188187
.map((item) => item.file_path)
189188
.filter((p): p is string => p !== undefined)
189+
190+
if (selected.length == 0) {
191+
vscode.window.showInformationMessage(
192+
t('feature.search-files.info.no-files-selected')
193+
)
194+
return
195+
}
196+
197+
is_resolved = true
190198
resolve({
191199
action: 'search-in-results',
192200
matched_paths: selected,

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,18 @@ export const prompt_for_search_results = async (params: {
168168
resolve('back')
169169
quick_pick.hide()
170170
} else if (button === search_in_results_button) {
171-
is_accepted = true
172171
const selected = quick_pick.selectedItems
173172
.map((item) => item.file_path)
174173
.filter((p): p is string => p !== undefined)
174+
175+
if (selected.length == 0) {
176+
vscode.window.showInformationMessage(
177+
t('feature.search-files.info.no-files-selected')
178+
)
179+
return
180+
}
181+
182+
is_accepted = true
175183
resolve({
176184
action: 'search-in-results',
177185
matched_paths: selected,

‎apps/editor/src/i18n/translations/features/search-files.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ export const translations = {
954954
bg: 'Търсене както в съдържанието, така и в имената на файловете'
955955
},
956956
'feature.search-files.results.unmatched': {
957-
en: 'unmatched Selected Files',
957+
en: 'unmatched selected files',
958958
pl: 'Niedopasowane wybrane pliki',
959959
'zh-cn': '未匹配的选定文件',
960960
ja: '一致しない選択されたファイル',
@@ -970,5 +970,23 @@ export const translations = {
970970
cs: 'Neodpovídající vybrané soubory',
971971
hu: 'Nem egyező kiválasztott fájlok',
972972
bg: 'Несъвпадащи избрани файлове'
973+
},
974+
'feature.search-files.info.no-files-selected': {
975+
en: 'Please select results search in.',
976+
pl: 'Proszę wybrać wyniki do przeszukania.',
977+
'zh-cn': '请选择要搜索的结果。',
978+
ja: '検索する結果を選択してください。',
979+
'zh-tw': '請選擇要搜尋的結果。',
980+
de: 'Bitte wählen Sie Ergebnisse für die Suche aus.',
981+
es: 'Por favor, seleccione los resultados en los que buscar.',
982+
fr: 'Veuillez sélectionner les résultats dans lesquels rechercher.',
983+
'pt-br': 'Por favor, selecione os resultados para pesquisar.',
984+
ru: 'Пожалуйста, выберите результаты для поиска.',
985+
ko: '검색할 결과를 선택하세요.',
986+
it: 'Seleziona i risultati in cui cercare.',
987+
tr: 'Lütfen arama yapılacak sonuçları seçin.',
988+
cs: 'Vyberte výsledky, ve kterých chcete hledat.',
989+
hu: 'Kérjük, válassza ki a keresendő eredményeket.',
990+
bg: 'Моля, изберете резултати, в които да търсите.'
973991
}
974992
} as const

0 commit comments

Comments
 (0)