cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.09k stars 200 forks source link

Autocomplete middle of token does not remove trailing matching content #41

Open Rush opened 7 years ago

Rush commented 7 years ago

Awesome lib. I have a problem with autocompletion though. How to reproduce:

Run:

var term = require( 'terminal-kit' ).terminal ;

var history = [ 'John' , 'Jack' , 'Joey' , 'Billy' , 'Bob' ] ;

var autoComplete = [
    'Barack Obama' , 'George W. Bush' , 'Bill Clinton' , 'George Bush' ,
    'Ronald W. Reagan' , 'Jimmy Carter' , 'Gerald Ford' , 'Richard Nixon' ,
    'Lyndon Johnson' , 'John F. Kennedy' , 'Dwight Eisenhower' ,
    'Harry Truman' , 'Franklin Roosevelt'
] ;

term( 'Please enter your name: ' ) ;

term.inputField(
    { history: history , autoComplete: autoComplete , autoCompleteMenu: true } ,
    function( error , input ) {

        term.green( "\nYour name is '%s'\n" , input ) ;
        process.exit() ;
    }
) ;

Enter some matching input and move cursor to the left: screenshot

now press TAB: Input will now be broken screenshot

Expected result: Auto-complete should recognize that the content following cursor is part of the matched completion and overwrite it.

cronvel commented 7 years ago

@Rush that's right, it auto-completes up to the current cursor position, but it's actually a feature. You get the same behavior in bash.

Is there some shell/readline-like piece of software you are used to that works the other way?