@@ -27,7 +27,13 @@ export const apply_context_command = (
2727 async ( ) => {
2828 let show_main_menu = true
2929 let last_main_selection_value = extension_context . workspaceState . get <
30- 'internal' | 'file' | 'other' | string | undefined
30+ | 'internal'
31+ | 'file'
32+ | 'unstaged'
33+ | 'commit_files'
34+ | 'check_all_with_keywords'
35+ | string
36+ | undefined
3137 > ( LAST_APPLY_CONTEXT_OPTION_STATE_KEY )
3238
3339 while ( show_main_menu ) {
@@ -51,7 +57,13 @@ export const apply_context_command = (
5157 }
5258
5359 const main_quick_pick_options : ( vscode . QuickPickItem & {
54- value : 'internal' | 'file' | 'other' | string
60+ value :
61+ | 'internal'
62+ | 'file'
63+ | 'unstaged'
64+ | 'commit_files'
65+ | 'check_all_with_keywords'
66+ | string
5567 } ) [ ] = [ ]
5668
5769 main_quick_pick_options . push ( {
@@ -77,13 +89,29 @@ export const apply_context_command = (
7789 } )
7890
7991 main_quick_pick_options . push ( {
80- label : 'Other...' ,
81- value : 'other'
92+ label : 'Unstaged files' ,
93+ value : 'unstaged'
94+ } )
95+
96+ main_quick_pick_options . push ( {
97+ label : 'Files of a commit...' ,
98+ value : 'commit_files'
99+ } )
100+
101+ main_quick_pick_options . push ( {
102+ label : 'Check all with keywords...' ,
103+ value : 'check_all_with_keywords'
82104 } )
83105
84106 const main_quick_pick = vscode . window . createQuickPick <
85107 vscode . QuickPickItem & {
86- value : 'internal' | 'file' | 'other' | string
108+ value :
109+ | 'internal'
110+ | 'file'
111+ | 'unstaged'
112+ | 'commit_files'
113+ | 'check_all_with_keywords'
114+ | string
87115 }
88116 > ( )
89117 main_quick_pick . title = 'Context Sources'
@@ -103,7 +131,13 @@ export const apply_context_command = (
103131
104132 const main_selection = await new Promise <
105133 | ( vscode . QuickPickItem & {
106- value : 'internal' | 'file' | 'other' | string
134+ value :
135+ | 'internal'
136+ | 'file'
137+ | 'unstaged'
138+ | 'commit_files'
139+ | 'check_all_with_keywords'
140+ | string
107141 triggeredButton ?: vscode . QuickInputButton
108142 } )
109143 | undefined
@@ -208,120 +242,24 @@ export const apply_context_command = (
208242 if ( result == 'back' ) {
209243 show_main_menu = true
210244 }
211- } else if ( main_selection . value == 'other' ) {
212- let show_other_menu = true
213- let last_other_selection_value : string | undefined
214-
215- while ( show_other_menu ) {
216- show_other_menu = false
217-
218- const other_quick_pick_options : ( vscode . QuickPickItem & {
219- value ?: 'unstaged' | 'commit_files' | 'check_all_with_keywords'
220- } ) [ ] = [
221- {
222- label : 'Unstaged files' ,
223- value : 'unstaged'
224- } ,
225- {
226- label : 'Files of a commit...' ,
227- value : 'commit_files'
228- } ,
229- {
230- label : 'Check all with keywords...' ,
231- value : 'check_all_with_keywords'
232- }
233- ]
234-
235- const other_quick_pick = vscode . window . createQuickPick <
236- vscode . QuickPickItem & {
237- value ?: 'unstaged' | 'commit_files' | 'check_all_with_keywords'
238- }
239- > ( )
240- other_quick_pick . title = 'Context Sources'
241- other_quick_pick . items = other_quick_pick_options
242- other_quick_pick . placeholder = 'Select other option'
243- other_quick_pick . buttons = [ vscode . QuickInputButtons . Back ]
244-
245- if ( last_other_selection_value ) {
246- const active_item = other_quick_pick_options . find (
247- ( opt ) => opt . value === last_other_selection_value
248- )
249- if ( active_item ) {
250- other_quick_pick . activeItems = [ active_item ]
251- }
252- }
253-
254- const other_selection = await new Promise <
255- | 'back'
256- | ( vscode . QuickPickItem & {
257- value ?:
258- | 'unstaged'
259- | 'commit_files'
260- | 'check_all_with_keywords'
261- } )
262- | undefined
263- > ( ( resolve ) => {
264- let is_accepted = false
265- let did_trigger_back = false
266- const disposables : vscode . Disposable [ ] = [ ]
267-
268- disposables . push (
269- other_quick_pick . onDidTriggerButton ( ( button ) => {
270- if ( button === vscode . QuickInputButtons . Back ) {
271- did_trigger_back = true
272- other_quick_pick . hide ( )
273- resolve ( 'back' )
274- }
275- } ) ,
276- other_quick_pick . onDidAccept ( ( ) => {
277- is_accepted = true
278- resolve ( other_quick_pick . selectedItems [ 0 ] )
279- other_quick_pick . hide ( )
280- } ) ,
281- other_quick_pick . onDidHide ( ( ) => {
282- if ( ! is_accepted && ! did_trigger_back ) {
283- resolve ( 'back' )
284- }
285- disposables . forEach ( ( d ) => d . dispose ( ) )
286- other_quick_pick . dispose ( )
287- } )
288- )
289- other_quick_pick . show ( )
290- } )
291-
292- if ( ! other_selection || other_selection == 'back' ) {
293- show_main_menu = true
294- break
295- }
296-
297- last_other_selection_value = other_selection . value
298-
299- if ( other_selection . value == 'unstaged' ) {
300- await handle_unstaged_files_source ( workspace_provider )
301- return
302- }
303- if ( other_selection . value == 'commit_files' ) {
304- const result = await handle_commit_files_source (
305- workspace_provider ,
306- extension_context
307- )
308- if ( result == 'back' ) {
309- show_other_menu = true
310- continue
311- }
312- return
313- }
314- if ( other_selection . value == 'check_all_with_keywords' ) {
315- const result = await handle_check_all_with_keywords_source (
316- workspace_provider ,
317- extension_context
318- )
319- if ( result == 'back' ) {
320- show_other_menu = true
321- continue
322- }
323- return
324- }
245+ } else if ( main_selection . value == 'unstaged' ) {
246+ await handle_unstaged_files_source ( workspace_provider )
247+ return
248+ } else if ( main_selection . value == 'commit_files' ) {
249+ const result = await handle_commit_files_source (
250+ workspace_provider ,
251+ extension_context
252+ )
253+ if ( result == 'back' ) {
254+ show_main_menu = true
255+ }
256+ } else if ( main_selection . value == 'check_all_with_keywords' ) {
257+ const result = await handle_check_all_with_keywords_source (
258+ workspace_provider ,
259+ extension_context
260+ )
261+ if ( result == 'back' ) {
262+ show_main_menu = true
325263 }
326264 }
327265 }
0 commit comments