@@ -506,41 +506,43 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) {
506
506
return ;
507
507
}
508
508
509
- const completions = rv [ 0 ] ;
510
- const completeOn = rv [ 1 ] ; // The text that was completed
511
- if ( completions && completions . length ) {
512
- // Apply/show completions.
513
- if ( lastKeypressWasTab ) {
514
- self . _writeToOutput ( '\r\n' ) ;
515
- const width = completions . reduce ( function completionReducer ( a , b ) {
516
- return a . length > b . length ? a : b ;
517
- } ) . length + 2 ; // 2 space padding
518
- let maxColumns = MathFloor ( self . columns / width ) ;
519
- if ( ! maxColumns || maxColumns === Infinity ) {
520
- maxColumns = 1 ;
521
- }
522
- let group = [ ] ;
523
- for ( let i = 0 ; i < completions . length ; i ++ ) {
524
- const c = completions [ i ] ;
525
- if ( c === '' ) {
526
- handleGroup ( self , group , width , maxColumns ) ;
527
- group = [ ] ;
528
- } else {
529
- group . push ( c ) ;
530
- }
531
- }
532
- handleGroup ( self , group , width , maxColumns ) ;
533
- }
509
+ // Result and the text that was completed.
510
+ const [ completions , completeOn ] = rv ;
511
+
512
+ if ( ! completions || completions . length === 0 ) {
513
+ return ;
514
+ }
534
515
535
- // If there is a common prefix to all matches, then apply that portion.
536
- const f = completions . filter ( ( e ) => e ) ;
537
- const prefix = commonPrefix ( f ) ;
538
- if ( prefix . length > completeOn . length ) {
539
- self . _insertString ( prefix . slice ( completeOn . length ) ) ;
516
+ // Apply/show completions.
517
+ if ( lastKeypressWasTab ) {
518
+ self . _writeToOutput ( '\r\n' ) ;
519
+ const width = completions . reduce ( ( a , b ) => {
520
+ return a . length > b . length ? a : b ;
521
+ } ) . length + 2 ; // 2 space padding
522
+ let maxColumns = MathFloor ( self . columns / width ) ;
523
+ if ( ! maxColumns || maxColumns === Infinity ) {
524
+ maxColumns = 1 ;
540
525
}
526
+ let group = [ ] ;
527
+ for ( const c of completions ) {
528
+ if ( c === '' ) {
529
+ handleGroup ( self , group , width , maxColumns ) ;
530
+ group = [ ] ;
531
+ } else {
532
+ group . push ( c ) ;
533
+ }
534
+ }
535
+ handleGroup ( self , group , width , maxColumns ) ;
536
+ }
541
537
542
- self . _refreshLine ( ) ;
538
+ // If there is a common prefix to all matches, then apply that portion.
539
+ const f = completions . filter ( ( e ) => e ) ;
540
+ const prefix = commonPrefix ( f ) ;
541
+ if ( prefix . length > completeOn . length ) {
542
+ self . _insertString ( prefix . slice ( completeOn . length ) ) ;
543
543
}
544
+
545
+ self . _refreshLine ( ) ;
544
546
} ) ;
545
547
} ;
546
548
0 commit comments