nushell / nushell

A new type of shell
https://www.nushell.sh/
MIT License
32.47k stars 1.68k forks source link

Multiline promtps override previous line when exiting Neovim #12104

Open zDonik1 opened 8 months ago

zDonik1 commented 8 months ago

Describe the bug

When extitng Neovim, if the custom prompt returned is more than 1 line, the last line of the new prompt is overriden, then recreating the prompt.

How to reproduce

  1. Set the prompt function to return a multi-line prompt: $env.PROMPT_COMMAND = {|| "nushell\n--" }
  2. Restart nushell
  3. Open neovim and exit
  4. Start typing a new command (eg. nvim)

Expected behavior

A prompt is not skipped, and the last line is not deleted/overridden.

Screenshots

image

Configuration

key value
version 0.90.1
branch
commit_hash c2992d5d8b8541b64e9fc1440ed2917fc9b757f7
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel 1.73.0-x86_64-pc-windows-msvc
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2024-02-07 02:25:09 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

fdncred commented 8 months ago

Does the same thing happen on 0.91.0?

zDonik1 commented 8 months ago

Didn't notice an update came out, I installed nu a few days ago. Anyhow, the problem still persists:

image

the entire config.nu is just $env.PROMPT_COMMAND = {|| "nushell\n--" }.

And here is the table again:

key value
version 0.91.0
branch
commit_hash 3016d7a64ccb2c2eac9f735f6144fc896ea724a5
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.74.1 (a28077b28 2023-12-04)
rust_channel 1.74.1-x86_64-pc-windows-msvc
cargo_version cargo 1.74.1 (ecb9851af 2023-10-18)
build_time 2024-03-05 20:48:22 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins
fdncred commented 8 months ago

I don't have this problem, but my prompt is different. I set my newline in the prompt indicator instead of the prompt.

# prompt
use modules\prompt\oh-my.nu git_prompt
$env.PROMPT_COMMAND = {|| (git_prompt).left_prompt }
$env.PROMPT_COMMAND_RIGHT = {|| (git_prompt).right_prompt }
$env.PROMPT_INDICATOR = {|| if ($env.LAST_EXIT_CODE == 0) {$"(ansi green_bold)\n❯ (ansi reset)"} else {$"(ansi red_bold)\n❯ (ansi reset)"}}
$env.TRANSIENT_PROMPT_COMMAND = ""
$env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| (git_prompt).right_prompt }
$env.TRANSIENT_PROMPT_INDICATOR = {|| if ($env.LAST_EXIT_CODE == 0) {$"(ansi light_yellow_bold)❯ (ansi reset)"} else {$"(ansi light_red_bold)❯ (ansi reset)"}}

However, I can reproduce your experience with nu -n and then $env.PROMPT_COMMAND = {|| "nushell\n--" }. I'm not sure why it's redrawing the prompt. I'm guessing this is a reeline problem. Also, a key point is that the prompt looks fine until you start typing (your point 4 above).

zDonik1 commented 8 months ago

I personally use Starship's default configuration for prompts, and their prompts start with a new line. Thanks for checking the issue out.

Mrhyuan commented 7 months ago

Yes same here. I can reproduce it as well. Im on Windows 11 using alacritty 0.91.0 + nushell + starship + neovim.

sibouras commented 6 months ago

this also happens when the terminal is resized, a workaround is using print, $env.PROMPT_COMMAND = {|| print 'nushell' } and after some testing it works fine besides the shift when empty list is returned(by [] for example), empty record works fine though!