oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.85k stars 159 forks source link

Incremental search overlaps long `PS1` #2081

Open nisbet-hubbard opened 1 month ago

nisbet-hubbard commented 1 month ago

When PS1 is long enough, launching an incremental search doesn’t dismiss the prompt:

[root@longhostname root]# 
(i-search)`': name root]# 

The prompt goes away entirely only after the length of the search terms exceeds it.

Sometimes, it can linger on like this:

oils-for-unix-0.23.0]# lr _build/oils.shnix-0.23.0]# 
andychu commented 1 month ago

Thanks for the report, I reproduced this ... I'm not sure why this is happening since we are basically just calling GNU readline with a prompt string

Maybe we are calling it the wrong way, or maybe it doesn't calculate the width correctly

andychu commented 1 month ago

Hm this happens in both Python and C++ - bin/osh and _bin/cxx-asan/osh

the former calls line_input() directly

But it doesn't happen in demo/cpython/readline_mod.py , which also ends up calling raw_input(), in frontend/py_readline.py

that is odd

andychu commented 1 month ago

Oh man I tracked this down to

core/comp_ui.py:    readline.parse_and_bind('set horizontal-scroll-mode on') 

disabling that restores the bash-like behavior

I added that in order to fix an issue with line wrapping, and our custom completion UI

Gah

we are trying to complete in a nicer way than bash, by not re-printing the prompt all the time, but it appears that GNU readline may not support that without bugs

I guess we could change the default back to something bash-like, and provide the current behavior as an option (which I like better)