@@ -11,12 +11,16 @@ export const prompt_for_provided_results = async (params: {
1111 files : { path : string ; checked : boolean } [ ]
1212 workspace_provider : WorkspaceProvider
1313 restored_selected_paths ?: string [ ]
14+ restored_unmatched_paths ?: string [ ]
15+ is_search_in_selected ?: boolean
16+ searched_files ?: string [ ]
1417} ) : Promise <
1518 | { selected_paths : string [ ] ; matched_paths : string [ ] ; title : string }
1619 | {
1720 action : 'search-in-results'
1821 matched_paths : string [ ]
1922 selected_paths : string [ ]
23+ unmatched_paths : string [ ]
2024 }
2125 | undefined
2226> => {
@@ -37,9 +41,20 @@ export const prompt_for_provided_results = async (params: {
3741 tooltip : t ( 'common.search-in-selected-results' )
3842 }
3943
44+ const currently_checked = params . workspace_provider . get_checked_files ( )
4045 const is_multi_root =
4146 params . workspace_provider . get_workspace_roots ( ) . length > 1
4247
48+ const matched_paths = params . files . map ( ( f ) => f . path )
49+
50+ const unmatched_checked_files =
51+ params . restored_unmatched_paths ??
52+ ( params . is_search_in_selected
53+ ? ( params . searched_files || currently_checked ) . filter (
54+ ( f ) => currently_checked . includes ( f ) && ! matched_paths . includes ( f )
55+ )
56+ : [ ] )
57+
4358 const mapped_items = await map_files_to_quick_pick_items ( {
4459 files : params . files ,
4560 is_multi_root,
@@ -57,6 +72,25 @@ export const prompt_for_provided_results = async (params: {
5772 checked ?: boolean
5873 } ) [ ]
5974
75+ if ( unmatched_checked_files . length > 0 ) {
76+ const mapped_unmatched_items = await map_files_to_quick_pick_items ( {
77+ files : unmatched_checked_files . map ( ( path ) => ( { path } ) ) ,
78+ is_multi_root,
79+ workspace_provider : params . workspace_provider ,
80+ open_file_button,
81+ add_parent_folder_button
82+ } )
83+
84+ const unmatched_quick_pick_items = group_quick_pick_items ( {
85+ mapped_items : mapped_unmatched_items ,
86+ is_multi_root : false ,
87+ workspace_provider : params . workspace_provider ,
88+ label_prefix : t ( 'feature.search-files.results.unmatched' )
89+ } ) as ( vscode . QuickPickItem & { file_path ?: string } ) [ ]
90+
91+ quick_pick_items . push ( ...unmatched_quick_pick_items )
92+ }
93+
6094 const quick_pick = vscode . window . createQuickPick <
6195 vscode . QuickPickItem & { file_path ?: string ; checked ?: boolean }
6296 > ( )
@@ -66,7 +100,10 @@ export const prompt_for_provided_results = async (params: {
66100 if ( params . restored_selected_paths ) {
67101 return params . restored_selected_paths . includes ( item . file_path )
68102 }
69- return item . checked
103+ if ( unmatched_checked_files . includes ( item . file_path ) ) {
104+ return false
105+ }
106+ return item . checked !== undefined ? item . checked : false
70107 } )
71108 quick_pick . canSelectMany = true
72109 quick_pick . matchOnDescription = true
@@ -103,6 +140,7 @@ export const prompt_for_provided_results = async (params: {
103140 action : 'search-in-results'
104141 matched_paths : string [ ]
105142 selected_paths : string [ ]
143+ unmatched_paths : string [ ]
106144 }
107145 | undefined
108146 > ( ( resolve ) => {
@@ -125,7 +163,8 @@ export const prompt_for_provided_results = async (params: {
125163 resolve ( {
126164 action : 'search-in-results' ,
127165 matched_paths : selected ,
128- selected_paths : selected
166+ selected_paths : selected ,
167+ unmatched_paths : unmatched_checked_files
129168 } )
130169 quick_pick . hide ( )
131170 } else if ( button === close_button ) {
@@ -140,7 +179,10 @@ export const prompt_for_provided_results = async (params: {
140179 selected_paths : quick_pick . selectedItems
141180 . map ( ( item ) => item . file_path )
142181 . filter ( ( p ) : p is string => p !== undefined ) ,
143- matched_paths : params . files . map ( ( f ) => f . path ) ,
182+ matched_paths : [
183+ ...params . files . map ( ( f ) => f . path ) ,
184+ ...unmatched_checked_files
185+ ] ,
144186 title : base_title
145187 } )
146188 quick_pick . hide ( )
0 commit comments