nushell
nushell copied to clipboard
significant flickering with nushell on windows using oh-my.nu
Describe the bug
with every character typed the screen flickers see gifs below. it works fine in 0.65.0.
git bisect says 98126e298175ed78a5797bacc06d0704a30b1785 is the first bad commit
I don't really understand what is going on and why this PR is causing issues.
How to reproduce
run nushell on windows terminal with oh-my.nu custom prompt. it may happen with other prompts too, i'm not sure. i'm also not sure if it happens on other operating systems. i haven't noticed it on my mac but maybe redraw/flicker is so fast i don't see it.
Expected behavior
no flickering
Screenshots
both these gifs demonstrate the flicker/redraw/blink but they don't capture it perfectly. it flickers on every keystroke. the gifs miss some flickers.
In WezTerm it's horrendous and redraws the prompt on every single character
Configuration
key | value |
---|---|
version | 0.66.3 |
branch | |
commit_hash | 56069af42d2b62b594d88668a1ce85a8697b58e6 |
build_os | windows-x86_64 |
build_target | x86_64-pc-windows-msvc |
rust_version | rustc 1.62.0 (a8314ef7d 2022-06-27) |
rust_channel | stable-x86_64-pc-windows-msvc |
cargo_version | cargo 1.62.0 (a748cf5a3 2022-06-08) |
pkg_version | 0.66.3 |
build_time | 2022-08-02 10:22:29 -05:00 |
build_rust_channel | release |
features | database, dataframe, default, trash, which, zip |
installed_plugins | gstat, inc, nu-example-1, nu-example-2, nu-example-3, query, query json, query web, query xml |
Additional context
No response
I've tracked it down to this https://github.com/nushell/nushell/blob/233afebdf0bf4df9fedd8232da93c963ae91bc19/crates/nu-cli/src/prompt_update.rs#L97-L117. Unfortunately, I'm not sure how to proceed from here because any modification of left_prompt_string
causes flickering. The only other idea I have is exposing the string from reedline for manipulation but I'm open to ideas.
I give up on this. 😭 I've tried 5 or so ways to try and prevent this flickering by moving this shell integration settings around but every time the prompt is updated flicker occurs. I've even tried augmenting the reedline trait so that in the repl.rs i can update the left prompt string, after the prompt is initially set but it resulted in the same flickering.
The flicker is super aggravating but apparently no one else on windows uses a heavily customized prompt. So, i'll have to wait until someone care enough and is smart enough to fix it. :)
Update: This is reproduceable with the prompt in our default_env.nu (below) so it's not related to my prompt script. It's related to every custom prompt.
def create_left_prompt [] {
let path_segment = if (is-admin) {
$"(ansi red_bold)($env.PWD)"
} else {
$"(ansi green_bold)($env.PWD)"
}
$path_segment
}
def create_right_prompt [] {
let time_segment = ([
(date now | date format '%m/%d/%Y %r')
] | str collect)
$time_segment
}
# Use nushell functions to define your right and left prompt
let-env PROMPT_COMMAND = { create_left_prompt }
let-env PROMPT_COMMAND_RIGHT = { create_right_prompt }
I'm noticing flicker when typing too (mostly default config, Windows Terminal, Nu running on both Windows+WSL). I did a git bisect
and it seems like the VS Code changes (#6087) are the culprit.
edit: I need to read before investigating things, I noticed that you also pinpointed the exact PR. My bad 😅
LOL. Yes, flickering on Windows is horrible. I can't figure it out. My guess is that it's not this PR directly because it's silly that this code change would cause a flicker for each character you type. I think this PR is a symptom, not the problem.
@fdncred figured out that this is only happening in Windows Terminal Preview v1.15 (thanks!).
In Preview v1.15 they added experimental scroll mark support, which is also the subject of #6087 so... there must be some bad interaction between our scroll mark output and WT.
Disabling scroll mark support in WT doesn't fix the issue, unfortunately.
@rgwood Do you think we should add an issue on the WT repo?
Yes I think that would be a good idea.
If you have time now, great; if not I can file an issue tonight or tomorrow.
@rgwood Would you mind doing it please, whenever you can get to it? Just ping me here with the issue number so i can subscribe to it.
@fdncred Filed: https://github.com/microsoft/terminal/issues/13710
Setting "shell_integration: false" in config.nu fixes the problem
Setting "shell_integration: false" in config.nu fixes the problem
@micgao correct. that's why I listed the commit that added that feature when I created this issue. disabling that feature is not a "fix".
commenting just to say that this also happens on WT Preview 1.16.2641.0, with nushell downloaded as-is from winget and the default config file. For any other beginners that (like me) stumble upon this issue as soon as they install nu: it's sufficient to comment the first section, up until let-env PROMPT_COMMAND_RIGHT = ...
(for me, that's lines 3 to 23), in the file %appdata%/nushell/env.nu
and the flickering completely stops.
I still get flicker in wt and wtp, even if the right prompt is removed.
The only thing I've found to resolve it with custom prompts is this let-env config = ($env.config | upsert shell_integration false)
Nu users: if this bothers you please upvote the Windows Terminal issue
Setting "shell_integration: false" in config.nu fixes the problem
Thanks, that's worked for me 🙇♂️
This problem is still there as of today. That said, setting "shell_integration: false" in config.nu did fix the flickering problem.
@g-berthiaume The issue is gone in the latest Windows Terminal Preview v1.18.1462
Ok thanks for the update.
So BTW, whatever causes this in Windows terminal also makes WezTerm do something weird, whenever I type a key it's adding a newline to my terminal output, thus pushing any content above the prompt upwards.
Setting shell_integration false fixes WezTerm as well.
@bartdorsey Yup, Wez was working on that last I checked. Trying to use the conpty that WT uses or something like that. https://github.com/nushell/nushell/issues/5585
I get this in ConEmu despite shell_integration
being set to false
in my config.nu. It doesn't seem to happen when the terminal is clear (i.e. the prompt is at the top of the window), but when I've issued a few commands and the prompt is about halfway down the window, it starts to flicker as I'm typing.
I think the root of this problem is that nushell/reedline redraws the prompt with every character typed. If you have a fast system and a fast terminal, it's not very noticeable. We'd love for someone to dig in and fix it in reedline.
However, this issue should be closed because it was specifically about Windows Terminal and that is fixed.
If this is an example of a broader issue, then please redirect it to that GitHub issue.