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