bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] {forward,reverse}-search-history binding bug


From: Yuriy Ershov
Subject: Re: [Bug-readline] {forward,reverse}-search-history binding bug
Date: Fri, 27 Oct 2017 15:55:56 +1100

Ah, it seems I understand what is happening!
In *-search-history mode there is no ANY delay allowed for ESC key.
It looks like in *-search-history mode readline is "previewing" the next input char and prefers to escape back to "normal" mode if there is anything unusual.
This is the way the Up and Down keys work.
Also, if *-search-history is bound to a key starting with ESC, it detects the next ESC key and bails out to the normal mode, leaving that ESC in the input queue.
Then readline reads the sequence: ah, there's a *-search-history command, let's do the search. But because it has just entered the mode, the buffer is empty.

Does it look like the truth?

On Fri, Oct 27, 2017 at 3:37 PM, Yuriy Ershov <address@hidden> wrote:
Chet, you are absolutely right: binding to a sequence without ESC works well.
But also I am sure there is no delay after initial ESC in the sequence.
Just because I am using a local terminal, the whole key sequence must be instantly appearing in the buffer.
In theory, there might be a casual delay just because of unexpected context switch or network disruptions but that can't be happening consistently every time.
So there may be an error waiting for that 0.1 sec timeout.

Took a quick look at the source: the default keyseq-timeout = 500ms (_rl_keyseq_timeout in C). And this is exactly what I see in my local readline vars.
Is it the same number used to timeout the ESC key?
I hardly believe I am that slow at typing :)

As I can see there is a quite complex state machine inside so I can't quickly work out what is happening in there but I imagine there may be some missing/dropped state that gets checked in _rl_isearch_dispatch (or maybe somewhere else).
This is just a guess though.


Cheers,
Yury


On Fri, Oct 27, 2017 at 1:21 AM, Chet Ramey <address@hidden> wrote:
On 10/26/17 4:21 AM, Yuriy Ershov wrote:
> Hi,
>
> TL;DR: binding of reverse-search-history and forward-search-history to a
> combination of more than one key leads to wrong behavior: the search string
> gets reset.

Does this happen with characters other than ESC?  ESC is special: it
cancels the search unless additional input is received within 0.1 seconds.
This is what allows the arrow keys to work while searching.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]