@@ -13,17 +13,14 @@ export const check_all_with_keywords_command = (
1313 return vscode . commands . registerCommand (
1414 'codeWebChat.checkAllWithKeywords' ,
1515 async ( item : any ) => {
16- if ( ! item || ! item . resourceUri ) {
17- return
18- }
19-
20- const folder_path = item . resourceUri . fsPath
16+ const folder_path = item ?. resourceUri ?. fsPath
2117
2218 try {
2319 const input_box = vscode . window . createInputBox ( )
2420 input_box . title = 'Keyword Search'
25- input_box . prompt = 'Enter keywords separated by comma'
26- input_box . placeholder = 'e.g. user, login, auth'
21+ input_box . prompt =
22+ 'Enter keywords separated by comma (use & for AND, quotes for whole words)'
23+ input_box . placeholder = 'e.g. user,login&auth,"ignoreFocus"'
2724
2825 const keywords_input = await new Promise < string | undefined > (
2926 ( resolve ) => {
@@ -63,12 +60,27 @@ export const check_all_with_keywords_command = (
6360
6461 const keywords = keywords_input
6562 . split ( ',' )
66- . map ( ( k ) => k . trim ( ) . toLowerCase ( ) )
67- . filter ( ( k ) => k . length > 0 )
63+ . map ( ( group ) =>
64+ group
65+ . split ( '&' )
66+ . map ( ( k ) => k . trim ( ) . toLowerCase ( ) )
67+ . filter ( ( k ) => k . length > 0 )
68+ )
69+ . filter ( ( group ) => group . length > 0 )
6870
6971 if ( keywords . length == 0 ) return
7072
71- const all_files = await workspace_provider . find_all_files ( folder_path )
73+ let all_files : string [ ] = [ ]
74+
75+ if ( folder_path ) {
76+ all_files = await workspace_provider . find_all_files ( folder_path )
77+ } else {
78+ const roots = workspace_provider . get_workspace_roots ( )
79+ for ( const root of roots ) {
80+ const files = await workspace_provider . find_all_files ( root )
81+ all_files . push ( ...files )
82+ }
83+ }
7284
7385 const matched_files = await search_files_by_keywords (
7486 all_files ,
@@ -158,17 +170,23 @@ export const check_all_with_keywords_command = (
158170 const selected_paths = selected_items . map ( ( item ) => item . file_path )
159171 const currently_checked = workspace_provider . get_checked_files ( )
160172
161- const files_outside_search_folder = currently_checked . filter ( ( file ) => {
162- const relative = path . relative ( folder_path , file )
163- return relative . startsWith ( '..' ) || path . isAbsolute ( relative )
164- } )
173+ let files_outside_search_folder : string [ ] = [ ]
174+ let files_inside_search_folder : string [ ] = [ ]
165175
166- let paths_to_apply = [ ...files_outside_search_folder , ...selected_paths ]
176+ if ( folder_path ) {
177+ files_outside_search_folder = currently_checked . filter ( ( file ) => {
178+ const relative = path . relative ( folder_path , file )
179+ return relative . startsWith ( '..' ) || path . isAbsolute ( relative )
180+ } )
181+ files_inside_search_folder = currently_checked . filter ( ( file ) => {
182+ const relative = path . relative ( folder_path , file )
183+ return ! relative . startsWith ( '..' ) && ! path . isAbsolute ( relative )
184+ } )
185+ } else {
186+ files_inside_search_folder = currently_checked
187+ }
167188
168- const files_inside_search_folder = currently_checked . filter ( ( file ) => {
169- const relative = path . relative ( folder_path , file )
170- return ! relative . startsWith ( '..' ) && ! path . isAbsolute ( relative )
171- } )
189+ let paths_to_apply = [ ...files_outside_search_folder , ...selected_paths ]
172190
173191 if ( files_inside_search_folder . length > 0 ) {
174192 const selected_paths_set = new Set ( selected_paths )
0 commit comments