Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental search overlaps long PS1 #2081

Open
nisbet-hubbard opened this issue Sep 26, 2024 · 6 comments
Open

Incremental search overlaps long PS1 #2081

nisbet-hubbard opened this issue Sep 26, 2024 · 6 comments

Comments

@nisbet-hubbard
Copy link
Contributor

nisbet-hubbard commented Sep 26, 2024

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
Copy link
Contributor

andychu commented Sep 27, 2024

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
Copy link
Contributor

andychu commented Sep 27, 2024

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 pushed a commit that referenced this issue Sep 27, 2024
Calling raw_input() doesn't exhibit the bug - it erases the prompt
correctly

Related to issue #2081
@andychu
Copy link
Contributor

andychu commented Sep 27, 2024

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)

andychu pushed a commit that referenced this issue Sep 27, 2024
This is issue #2081

It's due to GNU readline horizontal-scroll-mode

Unrelated: cases in spec/builtin-eval-test, with pp frame_vars_
@andychu
Copy link
Contributor

andychu commented Jan 17, 2025

@melvinw Thanks for finding this bug! I am not sure what to do about this, other than downgrade to the bash-like experience, which doesn't use "reuse the prompt line"

i.e. zsh and OSH reuse the prompt line, by printing ANSI sequences to go up, whereas bash doesn't

I feel that is nicer, but it causes this bug in OSH. (zsh has their own line editor of course; they don't use GNU readline)


It could be that GNU readline only correctly supports the bash-like behavior, and that's my suspicion, although I didn't look into it that deeply

https://oilshell.zulipchat.com/#narrow/channel/121539-oil-dev/topic/incremental.20search.20bug

@andychu
Copy link
Contributor

andychu commented Jan 17, 2025

Related issues

not sure if this is still desirable

@andychu
Copy link
Contributor

andychu commented Jan 17, 2025

So I think the problem is that if we try to do the zsh-like thing, we have either

I'm not sure if there is a way to solve both at once, within the constraints of GNU readline, but it would sure be nice !!

If we can't solve both, then I guess we fall back to a bash-like experience as the default?

melvinw added a commit that referenced this issue Jan 29, 2025
This will give users impacted by #2081 a remedy.
melvinw added a commit that referenced this issue Jan 30, 2025
This commit adds an environment variable for controlling readline's
horizontal-scroll-mode. You can now disable the scroll mode by setting
OILS_READLINE_HORIZONTAL_SCROLL_MODE=off.

This should help with #2081
andychu pushed a commit that referenced this issue Feb 2, 2025
- Don't set GNU readline horizontal-scroll-mode in minimal mode
  - This addresses issue #2081.
- In minimal mode, print completion candidates in columns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants