@@ -62,14 +62,13 @@ const get_completeable_arguments = async (term: WrappedTerminal) => {
6262 return null ;
6363 }
6464
65- // get the current argument partial
66- const current_arg_partial = args . length > 0 ? args [ args . length - 1 ] : "" ;
6765 const completion_data = {
6866 term,
69- args_so_far : args . slice ( 0 , - 1 ) ,
70- unsubbed_args_so_far : unsubbed_args . slice ( 0 , - 1 ) ,
71- raw_parts_so_far : raw_parts . slice ( 0 , - 1 ) ,
72- current_arg_partial,
67+ command,
68+ args,
69+ raw_parts : raw_parts ,
70+ unsubbed_args,
71+ current_partial : raw_parts [ raw_parts . length - 1 ] || "" ,
7372 } ;
7473
7574 const completion_result = await program . completion ( completion_data ) ;
@@ -189,9 +188,9 @@ export const tab_complete = async (term: WrappedTerminal, discard_cached_matches
189188
190189export const helper_completion_options = ( options : string [ ] ) => {
191190 return async function * ( data : CompletionData ) : AsyncGenerator < string > {
192- const { current_arg_partial } = data ;
191+ const { current_partial } = data ;
193192 for ( const option of options ) {
194- if ( option . startsWith ( current_arg_partial ) ) {
193+ if ( option . startsWith ( current_partial ) ) {
195194 yield option ;
196195 }
197196 }
@@ -200,11 +199,11 @@ export const helper_completion_options = (options: string[]) => {
200199
201200export const helper_completion_options_ordered = ( options : string [ ] [ ] ) => {
202201 return async function * ( data : CompletionData ) : AsyncGenerator < string > {
203- const { current_arg_partial , args_so_far } = data ;
204- const index = args_so_far . length ;
202+ const { current_partial , raw_parts } = data ;
203+ const index = raw_parts . length - 1 ;
205204 const options_at_index = options [ index ] || [ ] ;
206205 for ( const option of options_at_index ) {
207- if ( option . startsWith ( current_arg_partial ) ) {
206+ if ( option . startsWith ( current_partial ) ) {
208207 yield option ;
209208 }
210209 }
0 commit comments