@@ -56,13 +56,49 @@ export const find_relevant_files_command = (
5656 LAST_FIND_RELEVANT_FILES_QUERY_STATE_KEY
5757 ) || ''
5858
59+ const close_button = {
60+ iconPath : new vscode . ThemeIcon ( 'close' ) ,
61+ tooltip : t ( 'common.close' )
62+ }
63+
5964 while ( true ) {
60- const instructions = await vscode . window . showInputBox ( {
61- title : t ( 'command.find-relevant-files.input.title' ) ,
62- prompt : t ( 'command.find-relevant-files.input.prompt' ) ,
63- placeHolder : t ( 'command.find-relevant-files.input.placeholder' ) ,
64- value : initial_instructions
65- } )
65+ const input_box = vscode . window . createInputBox ( )
66+ input_box . title = t ( 'command.find-relevant-files.input.title' )
67+ input_box . prompt = t ( 'command.find-relevant-files.input.prompt' )
68+ input_box . placeholder = t (
69+ 'command.find-relevant-files.input.placeholder'
70+ )
71+ input_box . value = initial_instructions
72+ input_box . buttons = [ close_button ]
73+
74+ const instructions = await new Promise < string | undefined > (
75+ ( resolve ) => {
76+ let is_resolved = false
77+ const disposables : vscode . Disposable [ ] = [ ]
78+
79+ disposables . push (
80+ input_box . onDidTriggerButton ( ( button ) => {
81+ if ( button === close_button ) {
82+ resolve ( undefined )
83+ input_box . hide ( )
84+ }
85+ } ) ,
86+ input_box . onDidAccept ( ( ) => {
87+ is_resolved = true
88+ resolve ( input_box . value )
89+ input_box . hide ( )
90+ } ) ,
91+ input_box . onDidHide ( ( ) => {
92+ if ( ! is_resolved ) {
93+ resolve ( undefined )
94+ }
95+ disposables . forEach ( ( d ) => d . dispose ( ) )
96+ input_box . dispose ( )
97+ } )
98+ )
99+ input_box . show ( )
100+ }
101+ )
66102
67103 if ( ! instructions ) {
68104 return
@@ -252,7 +288,7 @@ export const find_relevant_files_command = (
252288 config_find_relevant_files_instructions ||
253289 find_relevant_files_instructions
254290
255- const system_instructions_xml = `${ instructions_to_use } \n${ find_relevant_files_format } `
291+ const system_instructions_xml = `${ find_relevant_files_format } \n${ instructions_to_use } `
256292 const part2 = `${ system_instructions_xml } \n${ instructions } `
257293
258294 const user_content = build_user_content ( {
@@ -389,10 +425,6 @@ export const find_relevant_files_command = (
389425 )
390426 quick_pick . ignoreFocusOut = true
391427
392- const close_button = {
393- iconPath : new vscode . ThemeIcon ( 'close' ) ,
394- tooltip : t ( 'common.close' )
395- }
396428 quick_pick . buttons = [ vscode . QuickInputButtons . Back , close_button ]
397429
398430 const selected = await new Promise <
@@ -445,6 +477,10 @@ export const find_relevant_files_command = (
445477 continue
446478 }
447479
480+ if ( ! selected ) {
481+ return
482+ }
483+
448484 if ( selected ) {
449485 const selected_paths = selected . map ( ( item ) => item . file_path )
450486 const unchecked_paths = absolute_paths . filter (
0 commit comments