hoaproject / Console

The Hoa\Console library.
https://hoa-project.net/
366 stars 32 forks source link

Autocompletion forgets counting extra spaces #67

Closed 1e1 closed 8 years ago

1e1 commented 8 years ago

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 ;)

Hywan commented 8 years ago

Hello,

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

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

Thanks!

1e1 commented 8 years ago
$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]
Hywan commented 8 years ago

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

Hywan commented 8 years ago

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

1e1 commented 8 years ago

Thx, it works!

Hywan commented 8 years ago

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

vonglasow commented 8 years ago

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