hoaproject / Console

The Hoa\Console library.

Home Page:https://hoa-project.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autocompletion forgets counting extra spaces

1e1 opened this issue · comments

commented

The autocompletion is OK while I'm typing a word. My word is completed, then I continue at the end.
I always add a space if my command has some words.

But if I typed a first word and the following space (or more) then I type "tab": my extra space is remove.
If I type again on "tab" the first letter of the previous word will be duplicate.

I guess LineLength is not updated when the autocompleter remove the ending space chars.
Moreover I would like one extra space after the autocompleted word ;)

Hello,

Can you please give us a detailed scenario, line by line, please? Something like:

$ hello<space>
$ hello<space><tab>
$ helloo

Thanks!

commented
$rl = new Hoa\Console\Readline\Readline();
$rl->setAutocompleter(new Hoa\Console\Readline\Autocompleter\Word([
    'help',
    'clear',
    'quit',
]));

do {
    $line = $rl->readLine('> ');
    // --- 
            echo '< ', $line;
    // ---

    echo PHP_EOL, PHP_EOL;
} while (false !== $line && 'quit' !== $line);

The shortest way:

$ quit<space><tab>[cursor][EOL]
$ qquit[cursor][EOL]

Indeeed, this is a bug. I will try to fix it.

@1e1 Can you test the patch in #68 please?

commented

Thx, it works!

@vonglasow seems to have some issue with #68. Let's wait on him.

It was due to run all tests with xdebug but without this library everything is good.