Skip to content

Commit daf4e55

Browse files
committed
Remove merge and replace context prompts from file selection commands
- don't offer replace/merge, always merge - remove now-unused translations [Changes]
1 parent e06efc8 commit daf4e55

10 files changed

Lines changed: 19 additions & 896 deletions

‎apps/editor/src/commands/search-files-commands.ts‎

Lines changed: 7 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Logger } from '@shared/utils/logger'
66
import { dictionary } from '@shared/constants/dictionary'
77
import { t } from '@/i18n'
88
import { search_files } from '@/features/search-files'
9-
import { LAST_FIND_RELEVANT_FILES_MERGE_REPLACE_OPTION_STATE_KEY } from '@/constants/state-keys'
109

1110
export const get_target_folder_path = async (
1211
item?: any
@@ -72,8 +71,6 @@ export const search_files_commands = (
7271
resolved_all_files.includes(f)
7372
)
7473

75-
let paths_to_apply: string[] = []
76-
7774
if (currently_checked_in_folder.length > 0) {
7875
const selected_paths_set = new Set(selected_paths)
7976
const is_identical =
@@ -88,99 +85,15 @@ export const search_files_commands = (
8885
)
8986
return
9087
}
91-
92-
const quick_pick_options = [
93-
{
94-
label: t('command.search-files.replace'),
95-
description: t('command.search-files.replace-description')
96-
},
97-
{
98-
label: t('command.search-files.merge'),
99-
description: t('command.search-files.merge-description')
100-
}
101-
]
102-
103-
const last_choice_label = extension_context.workspaceState.get<string>(
104-
LAST_FIND_RELEVANT_FILES_MERGE_REPLACE_OPTION_STATE_KEY
105-
)
106-
107-
const quick_pick_merge = vscode.window.createQuickPick()
108-
quick_pick_merge.items = quick_pick_options
109-
quick_pick_merge.placeholder = t(
110-
'command.search-files.apply-placeholder',
111-
{
112-
count: selected_paths.length
113-
}
114-
)
115-
116-
const close_button = {
117-
iconPath: new vscode.ThemeIcon('close'),
118-
tooltip: t('common.close')
119-
}
120-
quick_pick_merge.buttons = [vscode.QuickInputButtons.Back, close_button]
121-
122-
if (last_choice_label) {
123-
const active_item = quick_pick_options.find(
124-
(opt) => opt.label === last_choice_label
125-
)
126-
if (active_item) {
127-
quick_pick_merge.activeItems = [active_item]
128-
}
129-
}
130-
131-
const choice = await new Promise<
132-
vscode.QuickPickItem | 'back' | undefined
133-
>((resolve_choice) => {
134-
let is_accepted = false
135-
quick_pick_merge.onDidTriggerButton((button) => {
136-
if (button === vscode.QuickInputButtons.Back) {
137-
resolve_choice('back')
138-
quick_pick_merge.hide()
139-
} else if (button === close_button) {
140-
resolve_choice(undefined)
141-
quick_pick_merge.hide()
142-
}
143-
})
144-
quick_pick_merge.onDidAccept(() => {
145-
is_accepted = true
146-
resolve_choice(quick_pick_merge.selectedItems[0])
147-
quick_pick_merge.hide()
148-
})
149-
quick_pick_merge.onDidHide(() => {
150-
if (!is_accepted) resolve_choice(undefined)
151-
quick_pick_merge.dispose()
152-
})
153-
quick_pick_merge.show()
154-
})
155-
156-
if (choice == 'back' || !choice) {
157-
return
158-
}
159-
160-
await extension_context.workspaceState.update(
161-
LAST_FIND_RELEVANT_FILES_MERGE_REPLACE_OPTION_STATE_KEY,
162-
choice.label
163-
)
164-
165-
if (choice.label == t('command.search-files.merge')) {
166-
paths_to_apply = [
167-
...new Set([
168-
...currently_checked.filter((p) => !unchecked_paths.includes(p)),
169-
...selected_paths
170-
])
171-
]
172-
} else {
173-
paths_to_apply = [
174-
...new Set([
175-
...currently_checked.filter((p) => !resolved_all_files.includes(p)),
176-
...selected_paths
177-
])
178-
]
179-
}
180-
} else {
181-
paths_to_apply = [...new Set([...currently_checked, ...selected_paths])]
18288
}
18389

90+
const paths_to_apply = [
91+
...new Set([
92+
...currently_checked.filter((p) => !unchecked_paths.includes(p)),
93+
...selected_paths
94+
])
95+
]
96+
18497
await workspace_provider.set_checked_files(paths_to_apply)
18598

18699
Logger.info({

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

Lines changed: 3 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from 'path'
33
import * as fs from 'fs'
44
import { execSync } from 'child_process'
55
import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
6-
import { LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY } from '../constants/state-keys'
76
import { get_git_repository } from '@/utils/git-repository-utils'
87
import { Logger } from '@shared/utils/logger'
98
import { dictionary } from '@shared/constants/dictionary'
@@ -321,9 +320,6 @@ export const select_changed_files_command = (
321320
return
322321
}
323322

324-
let paths_to_apply = selected_paths
325-
let should_continue_file_loop = false
326-
327323
if (currently_checked.length > 0) {
328324
const selected_paths_set = new Set(selected_paths)
329325
const is_identical =
@@ -336,93 +332,11 @@ export const select_changed_files_command = (
336332
)
337333
return
338334
}
339-
340-
if (!is_identical) {
341-
const quick_pick_options = [
342-
{
343-
label: t('command.select-changed-files.replace'),
344-
description: t(
345-
'command.select-changed-files.replace-description'
346-
)
347-
},
348-
{
349-
label: t('command.select-changed-files.merge'),
350-
description: t(
351-
'command.select-changed-files.merge-description'
352-
)
353-
}
354-
]
355-
356-
const last_choice_label =
357-
extension_context.workspaceState.get<string>(
358-
LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY
359-
)
360-
361-
const quick_pick_merge = vscode.window.createQuickPick()
362-
quick_pick_merge.items = quick_pick_options
363-
quick_pick_merge.placeholder = t(
364-
'command.select-changed-files.apply',
365-
{
366-
branch: selected_branch.name
367-
}
368-
)
369-
quick_pick_merge.buttons = [vscode.QuickInputButtons.Back]
370-
371-
if (last_choice_label) {
372-
const active_item = quick_pick_options.find(
373-
(opt) => opt.label === last_choice_label
374-
)
375-
if (active_item) {
376-
quick_pick_merge.activeItems = [active_item]
377-
}
378-
}
379-
380-
const choice = await new Promise<
381-
vscode.QuickPickItem | 'back' | undefined
382-
>((resolve) => {
383-
let is_accepted = false
384-
quick_pick_merge.onDidTriggerButton((button) => {
385-
if (button === vscode.QuickInputButtons.Back) {
386-
resolve('back')
387-
quick_pick_merge.hide()
388-
}
389-
})
390-
quick_pick_merge.onDidAccept(() => {
391-
is_accepted = true
392-
resolve(quick_pick_merge.selectedItems[0])
393-
quick_pick_merge.hide()
394-
})
395-
quick_pick_merge.onDidHide(() => {
396-
if (!is_accepted) resolve('back')
397-
quick_pick_merge.dispose()
398-
})
399-
quick_pick_merge.show()
400-
})
401-
402-
if (choice === 'back') {
403-
should_continue_file_loop = true
404-
} else if (!choice) {
405-
return
406-
} else {
407-
await extension_context.workspaceState.update(
408-
LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY,
409-
choice.label
410-
)
411-
412-
if (
413-
choice.label === t('command.select-changed-files.merge')
414-
) {
415-
paths_to_apply = [
416-
...new Set([...currently_checked, ...selected_paths])
417-
]
418-
}
419-
}
420-
}
421335
}
422336

423-
if (should_continue_file_loop) {
424-
continue
425-
}
337+
const paths_to_apply = [
338+
...new Set([...currently_checked, ...selected_paths])
339+
]
426340

427341
await workspace_provider.set_checked_files(paths_to_apply)
428342

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

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as fs from 'fs'
44
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
55
import { get_all_workspace_files } from '@/context/helpers/get-all-workspace-files'
66
import { display_token_count } from '@/utils/display-token-count'
7-
import { LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY } from '@/constants/state-keys'
87
import { t } from '@/i18n'
98
import { Logger } from '@shared/utils/logger'
109
import { dictionary } from '@shared/constants/dictionary'
@@ -214,9 +213,7 @@ export const select_clipboard_paths_command = (
214213
return
215214
}
216215

217-
paths_to_apply = selected_paths
218216
final_selected_paths = selected_paths
219-
let should_continue_main_loop = false
220217

221218
if (currently_checked.length > 0) {
222219
const selected_paths_set = new Set(selected_paths)
@@ -230,93 +227,11 @@ export const select_clipboard_paths_command = (
230227
)
231228
return
232229
}
233-
234-
if (!is_identical) {
235-
const quick_pick_options = [
236-
{
237-
label: t('command.select-clipboard-paths.replace'),
238-
description: t(
239-
'command.select-clipboard-paths.replace-description'
240-
)
241-
},
242-
{
243-
label: t('command.select-clipboard-paths.merge'),
244-
description: t(
245-
'command.select-clipboard-paths.merge-description'
246-
)
247-
}
248-
]
249-
250-
const last_choice_label =
251-
extension_context.workspaceState.get<string>(
252-
LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY
253-
)
254-
255-
const quick_pick_merge = vscode.window.createQuickPick()
256-
quick_pick_merge.items = quick_pick_options
257-
quick_pick_merge.placeholder = t(
258-
'command.select-clipboard-paths.apply',
259-
{
260-
count: selected_paths.length
261-
}
262-
)
263-
quick_pick_merge.buttons = [vscode.QuickInputButtons.Back]
264-
265-
if (last_choice_label) {
266-
const active_item = quick_pick_options.find(
267-
(opt) => opt.label === last_choice_label
268-
)
269-
if (active_item) {
270-
quick_pick_merge.activeItems = [active_item]
271-
}
272-
}
273-
274-
const choice = await new Promise<
275-
vscode.QuickPickItem | 'back' | undefined
276-
>((resolve) => {
277-
let is_accepted = false
278-
quick_pick_merge.onDidTriggerButton((button) => {
279-
if (button === vscode.QuickInputButtons.Back) {
280-
resolve('back')
281-
quick_pick_merge.hide()
282-
}
283-
})
284-
quick_pick_merge.onDidAccept(() => {
285-
is_accepted = true
286-
resolve(quick_pick_merge.selectedItems[0])
287-
quick_pick_merge.hide()
288-
})
289-
quick_pick_merge.onDidHide(() => {
290-
if (!is_accepted) resolve('back')
291-
quick_pick_merge.dispose()
292-
})
293-
quick_pick_merge.show()
294-
})
295-
296-
if (choice === 'back') {
297-
should_continue_main_loop = true
298-
} else if (!choice) {
299-
return
300-
} else {
301-
await extension_context.workspaceState.update(
302-
LAST_APPLY_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY,
303-
choice.label
304-
)
305-
306-
if (
307-
choice.label === t('command.select-clipboard-paths.merge')
308-
) {
309-
paths_to_apply = [
310-
...new Set([...currently_checked, ...selected_paths])
311-
]
312-
}
313-
}
314-
}
315230
}
316231

317-
if (should_continue_main_loop) {
318-
continue
319-
}
232+
paths_to_apply = [
233+
...new Set([...currently_checked, ...selected_paths])
234+
]
320235

321236
break
322237
}

0 commit comments

Comments
 (0)