Skip to content

Commit fc40dbe

Browse files
committed
Refine modified files selection logic to support unselecting files and remove all-selected early exit
- should not break short the quick pick if all files are selected. keep showing the quick pick to let users uncheck some files there
1 parent 406e210 commit fc40dbe

2 files changed

Lines changed: 22 additions & 51 deletions

File tree

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

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,6 @@ export const select_modified_files_command = (
6868
const currently_selected = workspace_provider.get_selected_files()
6969
const currently_selected_set = new Set(currently_selected)
7070

71-
if (
72-
existing_modified_files.every((file) =>
73-
currently_selected_set.has(file)
74-
)
75-
) {
76-
vscode.window.showInformationMessage(
77-
t('command.select-modified-files-command.all-selected')
78-
)
79-
return
80-
}
81-
8271
const quick_pick_items = await Promise.all(
8372
existing_modified_files.map(async (file_path) => {
8473
const token_count =
@@ -209,10 +198,7 @@ export const select_modified_files_command = (
209198
quick_pick.show()
210199
})
211200

212-
if (
213-
!selected_items ||
214-
(Array.isArray(selected_items) && selected_items.length === 0)
215-
) {
201+
if (!selected_items) {
216202
return
217203
}
218204

@@ -241,28 +227,31 @@ export const select_modified_files_command = (
241227
selected_paths = selected_items.map((item) => item.file_path)
242228
}
243229

244-
if (selected_paths.length === 0) {
245-
return
246-
}
247-
248-
if (currently_selected.length > 0) {
249-
const selected_paths_set = new Set(selected_paths)
250-
const is_identical =
251-
currently_selected.length === selected_paths_set.size &&
252-
currently_selected.every((file) => selected_paths_set.has(file))
253-
254-
if (is_identical) {
255-
vscode.window.showInformationMessage(
256-
t('common.info.context-already-set')
257-
)
258-
return
259-
}
260-
}
230+
const selected_paths_set = new Set(selected_paths)
231+
const unchecked_modified_files = new Set(
232+
existing_modified_files.filter((f) => !selected_paths_set.has(f))
233+
)
261234

262235
const paths_to_apply = [
263-
...new Set([...currently_selected, ...selected_paths])
236+
...new Set([
237+
...currently_selected.filter(
238+
(file) => !unchecked_modified_files.has(file)
239+
),
240+
...selected_paths
241+
])
264242
]
265243

244+
const is_identical =
245+
currently_selected.length === paths_to_apply.length &&
246+
currently_selected.every((file) => paths_to_apply.includes(file))
247+
248+
if (is_identical) {
249+
vscode.window.showInformationMessage(
250+
t('common.info.context-already-set')
251+
)
252+
return
253+
}
254+
266255
Logger.info({
267256
message: `Selected ${selected_paths.length} modified file${
268257
selected_paths.length === 1 ? '' : 's'

‎apps/editor/src/i18n/translations/commands/select-modified-files-command.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,5 @@ export const translations = {
1616
cs: 'Upravené soubory',
1717
hu: 'Módosított fájlok',
1818
bg: 'Променени файлове'
19-
},
20-
'command.select-modified-files-command.all-selected': {
21-
en: 'All modified files are already selected.',
22-
pl: 'Wszystkie zmodyfikowane pliki są już zaznaczone.',
23-
'zh-cn': '所有修改的文件都已选中。',
24-
ja: '変更されたファイルはすべて既に選択されています。',
25-
'zh-tw': '所有修改的檔案都已選取。',
26-
de: 'Alle geänderten Dateien sind bereits ausgewählt.',
27-
es: 'Todos los archivos modificados ya están seleccionados.',
28-
fr: 'Tous les fichiers modifiés sont déjà sélectionnés.',
29-
'pt-br': 'Todos os arquivos modificados já estão selecionados.',
30-
ru: 'Все измененные файлы уже выбраны.',
31-
ko: '수정된 모든 파일이 이미 선택되었습니다.',
32-
it: 'Tutti i file modificati sono già selezionati.',
33-
tr: 'Değiştirilen tüm dosyalar zaten seçilmiş.',
34-
cs: 'Všechny upravené soubory jsou již vybrány.',
35-
hu: 'Minden módosított fájl már ki van választva.',
36-
bg: 'Всички променени файлове вече са избрани.'
3719
}
3820
} as const

0 commit comments

Comments
 (0)