@@ -3,10 +3,7 @@ import * as path from 'path'
33import * as fs from 'fs'
44import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
55import { Logger } from '@shared/utils/logger'
6- import {
7- LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY ,
8- LAST_SEARCH_FILES_FOR_CONTEXT_QUERY_STATE_KEY
9- } from '../constants/state-keys'
6+ import { LAST_SEARCH_FILES_FOR_CONTEXT_QUERY_STATE_KEY } from '../constants/state-keys'
107import { display_token_count } from '../utils/display-token-count'
118import { dictionary } from '@shared/constants/dictionary'
129import { t } from '../i18n'
@@ -272,95 +269,9 @@ export const search_files_for_context_commands = (
272269 selected_items as ( vscode . QuickPickItem & { file_path : string } ) [ ]
273270 ) . map ( ( item ) => item . file_path )
274271
275- let files_outside_search_folder : string [ ] = [ ]
276- let files_inside_search_folder : string [ ] = [ ]
277-
278- if ( folder_path ) {
279- files_outside_search_folder = currently_checked . filter ( ( file ) => {
280- const relative = path . relative ( folder_path , file )
281- return relative . startsWith ( '..' ) || path . isAbsolute ( relative )
282- } )
283- files_inside_search_folder = currently_checked . filter ( ( file ) => {
284- const relative = path . relative ( folder_path , file )
285- return ! relative . startsWith ( '..' ) && ! path . isAbsolute ( relative )
286- } )
287- } else {
288- files_inside_search_folder = currently_checked
289- }
290-
291- let paths_to_apply = [ ...files_outside_search_folder , ...selected_paths ]
292-
293- if ( files_inside_search_folder . length > 0 ) {
294- const selected_paths_set = new Set ( selected_paths )
295- const all_current_files_in_new_context =
296- files_inside_search_folder . every ( ( file ) =>
297- selected_paths_set . has ( file )
298- )
299-
300- if ( ! all_current_files_in_new_context ) {
301- const quick_pick_options = [
302- {
303- label : t ( 'command.search.replace' ) ,
304- description : t ( 'command.search.replace-description' )
305- } ,
306- {
307- label : t ( 'command.search.merge' ) ,
308- description : t ( 'command.search.merge-description' )
309- }
310- ]
311-
312- const last_choice_label =
313- extension_context . workspaceState . get < string > (
314- LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY
315- )
316-
317- const quick_pick_apply = vscode . window . createQuickPick ( )
318- quick_pick_apply . items = quick_pick_options
319- quick_pick_apply . placeholder = t (
320- 'command.search.apply-placeholder' ,
321- { count : selected_paths . length }
322- )
323- quick_pick_apply . ignoreFocusOut = true
324-
325- if ( last_choice_label ) {
326- const active_item = quick_pick_options . find (
327- ( opt ) => opt . label === last_choice_label
328- )
329- if ( active_item ) {
330- quick_pick_apply . activeItems = [ active_item ]
331- }
332- }
333-
334- const choice = await new Promise < vscode . QuickPickItem | undefined > (
335- ( resolve ) => {
336- let is_accepted = false
337- quick_pick_apply . onDidAccept ( ( ) => {
338- is_accepted = true
339- resolve ( quick_pick_apply . selectedItems [ 0 ] )
340- quick_pick_apply . hide ( )
341- } )
342- quick_pick_apply . onDidHide ( ( ) => {
343- if ( ! is_accepted ) resolve ( undefined )
344- quick_pick_apply . dispose ( )
345- } )
346- quick_pick_apply . show ( )
347- }
348- )
349-
350- if ( ! choice ) return
351-
352- await extension_context . workspaceState . update (
353- LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY ,
354- choice . label
355- )
356-
357- if ( choice . label == t ( 'command.search.merge' ) ) {
358- paths_to_apply = [
359- ...new Set ( [ ...currently_checked , ...selected_paths ] )
360- ]
361- }
362- }
363- }
272+ const paths_to_apply = [
273+ ...new Set ( [ ...currently_checked , ...selected_paths ] )
274+ ]
364275
365276 Logger . info ( {
366277 message : `Selected ${ selected_paths . length } files from search in folder.` ,
0 commit comments