AmokHuginnsson / replxx

A readline and libedit replacement that supports UTF-8, syntax highlighting, hints and Windows and is BSD licensed.
Other
691 stars 108 forks source link

Ctrl+S history search only refreshes when backspace is pressed #88

Closed nlebedenco closed 3 years ago

nlebedenco commented 4 years ago

Although reverse history search (Ctrl+R) works as expected, Ctrl+S does not print. No history entry matched is printed. Only after Backspace is pressed (and the resulting string still matches) that the prompt will be updated properly.

AmokHuginnsson commented 3 years ago

Can you explain precisely how Ctrl+S should work? replxxes Ctrl+S works just like readlines as far as I can tell.

nlebedenco commented 3 years ago

Build master (I used the same machine and binary from issue #89 for simplicity) In the open terminal type in

echo 1 [enter] echo 2 [enter] echo 3 [enter] echo 4 [enter]

Now if I type in Ctrl+R followed by the prefix 'ech' I see this: issue-88-Ctrl-R Which as expected displays "echo 4" as the last match Now open another terminal and repeat the process doing Ctrl+S in place of Ctrl+R. I see this: issue-88-Ctrl-S But I expected to see 'echo 1' as a match. Curiously if I hit backspace and leave the prefix 'ec' the terminal finds the expected match as shown below: issue-88-Ctrl-S-and-BKSP

AmokHuginnsson commented 3 years ago

Hmm. Do you expect for search to wrap around in history?

nlebedenco commented 3 years ago

Well I don't really know if there are variations to how libreadline handles Ctrl+S but I'd expect it to either always respect the current position in history if this is intended or always search from the beginning. However what appears to be happening is that it respects the current position except when bksp is pressed when it suddenly reverts to searching from the beginning which is odd.

AmokHuginnsson commented 3 years ago

Current (ee9b47bc018444652c1d37f7d5258ebd1c97ad1f) master should have more consistent behavior.

nlebedenco commented 3 years ago

This seems fixed now, thx.

Btw, for the record, I was surprised to realize that Ctrl-S/R are not strict prefix searches. But this is according to libreadline's behaviour from what I've checked on a bash terminal so this is all good.