77import { SavedContext } from '@/types/context'
88import { dictionary } from '@shared/constants/dictionary'
99import {
10- handle_clipboard_source ,
1110 handle_json_file_source ,
1211 handle_unstaged_files_source ,
1312 handle_workspace_state_source ,
@@ -51,12 +50,7 @@ export function apply_context_command(
5150
5251 const main_quick_pick_options : ( vscode . QuickPickItem & {
5352 value : 'internal' | 'file' | 'other'
54- } ) [ ] = [
55- {
56- label : 'Source' ,
57- kind : vscode . QuickPickItemKind . Separator
58- } as any
59- ]
53+ } ) [ ] = [ ]
6054
6155 main_quick_pick_options . push ( {
6256 label : 'Workspace state' ,
@@ -84,6 +78,7 @@ export function apply_context_command(
8478 const main_quick_pick = vscode . window . createQuickPick <
8579 vscode . QuickPickItem & { value : 'internal' | 'file' | 'other' }
8680 > ( )
81+ main_quick_pick . title = 'Select Source'
8782 main_quick_pick . items = final_quick_pick_options
8883 main_quick_pick . placeholder = 'Select option'
8984 if ( last_main_selection_value ) {
@@ -143,12 +138,9 @@ export function apply_context_command(
143138 show_main_menu = true
144139 }
145140 } else if ( main_selection . value == 'other' ) {
146- const BACK_LABEL = '$(arrow-left) Back'
147141 const other_quick_pick_options : ( vscode . QuickPickItem & {
148142 value ?: 'clipboard' | 'unstaged'
149143 } ) [ ] = [
150- { label : BACK_LABEL } ,
151- { label : '' , kind : vscode . QuickPickItemKind . Separator } ,
152144 {
153145 label : 'Select files based on paths found in the clipboard text' ,
154146 value : 'clipboard'
@@ -162,35 +154,53 @@ export function apply_context_command(
162154 const other_quick_pick = vscode . window . createQuickPick <
163155 vscode . QuickPickItem & { value ?: 'clipboard' | 'unstaged' }
164156 > ( )
157+ other_quick_pick . title = 'Select Source'
165158 other_quick_pick . items = other_quick_pick_options
166159 other_quick_pick . placeholder = 'Select other option'
160+ other_quick_pick . buttons = [ vscode . QuickInputButtons . Back ]
167161
168162 const other_selection = await new Promise <
163+ | 'back'
169164 | ( vscode . QuickPickItem & { value ?: 'clipboard' | 'unstaged' } )
170165 | undefined
171166 > ( ( resolve ) => {
172167 let is_accepted = false
173- other_quick_pick . onDidAccept ( ( ) => {
174- is_accepted = true
175- resolve ( other_quick_pick . selectedItems [ 0 ] )
176- other_quick_pick . hide ( )
177- } )
178- other_quick_pick . onDidHide ( ( ) => {
179- if ( ! is_accepted ) {
180- resolve ( undefined )
181- }
182- other_quick_pick . dispose ( )
183- } )
168+ let did_trigger_back = false
169+ const disposables : vscode . Disposable [ ] = [ ]
170+
171+ disposables . push (
172+ other_quick_pick . onDidTriggerButton ( ( button ) => {
173+ if ( button === vscode . QuickInputButtons . Back ) {
174+ did_trigger_back = true
175+ other_quick_pick . hide ( )
176+ resolve ( 'back' )
177+ }
178+ } ) ,
179+ other_quick_pick . onDidAccept ( ( ) => {
180+ is_accepted = true
181+ resolve ( other_quick_pick . selectedItems [ 0 ] )
182+ other_quick_pick . hide ( )
183+ } ) ,
184+ other_quick_pick . onDidHide ( ( ) => {
185+ if ( ! is_accepted && ! did_trigger_back ) {
186+ resolve ( 'back' )
187+ }
188+ disposables . forEach ( ( d ) => d . dispose ( ) )
189+ other_quick_pick . dispose ( )
190+ } )
191+ )
184192 other_quick_pick . show ( )
185193 } )
186194
187- if ( ! other_selection || other_selection . label === BACK_LABEL ) {
195+ if ( ! other_selection || other_selection === 'back' ) {
188196 show_main_menu = true
189197 continue
190198 }
191199
192200 if ( other_selection . value == 'clipboard' ) {
193- await handle_clipboard_source ( workspace_provider )
201+ await vscode . commands . executeCommand (
202+ 'codeWebChat.findPathsInClipboard'
203+ )
194204 return
195205 }
196206 if ( other_selection . value == 'unstaged' ) {
0 commit comments