Skip to content

Comments

fix: prompt duplication when resizing with non-empty right_prompt#894

Closed
blindFS wants to merge 2 commits intonushell:mainfrom
blindFS:prompt_start_row
Closed

fix: prompt duplication when resizing with non-empty right_prompt#894
blindFS wants to merge 2 commits intonushell:mainfrom
blindFS:prompt_start_row

Conversation

@blindFS
Copy link
Contributor

@blindFS blindFS commented Mar 24, 2025

Supposed to fix #864 , this method works well on my mac with ghostty/wezterm/terminal, but I need help to test on other terminal/os.

After:

Screen.Recording.2025-03-24.at.10.15.40.AM.mov

The prompt start position goes up with the line-wrapped text, which is the same behavior as zsh.

@fdncred
Copy link
Contributor

fdncred commented Mar 26, 2025

I tested it on macos. I don't think it's working right. I mean the right prompt drawing isn't bad but it just goes up the screen erasing the terminal one line at a time as it goes up.
resize

@blindFS
Copy link
Contributor Author

blindFS commented Mar 26, 2025

Oops, what terminal are you using in that?

@fdncred
Copy link
Contributor

fdncred commented Mar 26, 2025

Oops, what terminal are you using in that?

That's ghostty on macos

@blindFS
Copy link
Contributor Author

blindFS commented Mar 26, 2025

Oops, what terminal are you using in that?

That's ghostty on macos

Hmmm, interesting. That means my duplication experience could be caused by bad configuration, OMG.
Thanks for your effort, I'll take more look at it.

@blindFS blindFS marked this pull request as draft March 26, 2025 00:22
@blindFS
Copy link
Contributor Author

blindFS commented Mar 26, 2025

I've found out the minimal steps required to reproduce the bug with ghostty on macOS and the default nu config:

  1. multiline left prompt and non-empty right prompt (the default one is fine), $env.PROMPT_COMMAND = {|| "foo\nbar"}
  2. turn off osc133, either $env.config.shell_integration.osc133 = false, or open a tmux session in ghostty.

So it's definitely more complicated than I thought.

@fdncred
Copy link
Contributor

fdncred commented Mar 26, 2025

I was just running the reedline demo like this cargo run --example demo --features=sqlite,bashisms

@blindFS
Copy link
Contributor Author

blindFS commented Mar 26, 2025

I was just running the reedline demo like this cargo run --example demo --features=sqlite,bashisms

Oh, I mean the steps to reproduce #864.

There are many factors that can determine how long-line text gets wrapped in a terminal.

Due to my lack of knowledge about the terminal and OSC stuff, I can't find a proper way to locate the prompt start position given all those complications vary from app to app. So I'm going to close this PR for now.

However, the method used in current reedline implementation (find cursor first, then rewind back by counting \n in the text) certainly behaves worse compared to other shells like zsh/bash. I'll create another issue to elaborate that problem.

@blindFS blindFS closed this Mar 26, 2025
@blindFS blindFS deleted the prompt_start_row branch March 26, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Right prompt redraw issue in nu 0.101

2 participants