Multiline promtps override previous line when exiting Neovim
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
- Set the prompt function to return a multi-line prompt:
$env.PROMPT_COMMAND = {|| "nushell\n--" } - Restart nushell
- Open neovim and exit
- Start typing a new command (eg. nvim)
Expected behavior
A prompt is not skipped, and the last line is not deleted/overridden.
Screenshots
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
Does the same thing happen on 0.91.0?
Didn't notice an update came out, I installed nu a few days ago. Anyhow, the problem still persists:
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 |
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).
I personally use Starship's default configuration for prompts, and their prompts start with a new line. Thanks for checking the issue out.
Yes same here. I can reproduce it as well. Im on Windows 11 using alacritty 0.91.0 + nushell + starship + neovim.
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!