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

Flickering when typing in Windows Terminal #6214

Closed
fdncred opened this issue Aug 2, 2022 · 26 comments
Closed

Flickering when typing in Windows Terminal #6214

fdncred opened this issue Aug 2, 2022 · 26 comments
Labels
🐛 bug Something isn't working line editor Issues related to reedline

Comments

@fdncred
Copy link
Collaborator

fdncred commented Aug 2, 2022

Describe the bug

with every character typed the screen flickers see gifs below. it works fine in 0.65.0.

git bisect says
98126e2 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.
flicker1
flicker2
In WezTerm it's horrendous and redraws the prompt on every single character
flicker3

Configuration

key value
version 0.66.3
branch
commit_hash 56069af
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

@fdncred fdncred added the 🐛 bug Something isn't working label Aug 2, 2022
@sholderbach sholderbach added the line editor Issues related to reedline label Aug 2, 2022
@fdncred
Copy link
Collaborator Author

fdncred commented Aug 2, 2022

I've tracked it down to this

let left_prompt_string = get_prompt_string(
PROMPT_COMMAND,
config,
engine_state,
&mut stack,
is_perf_true,
);
// Now that we have the prompt string lets ansify it.
// <133 A><prompt><133 B><command><133 C><command output>
let left_prompt_string = if config.shell_integration {
match left_prompt_string {
Some(prompt_string) => Some(format!(
"{}{}{}",
PRE_PROMPT_MARKER, prompt_string, POST_PROMPT_MARKER
)),
None => left_prompt_string,
}
} else {
left_prompt_string
};
. 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.

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 3, 2022

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. :)

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 5, 2022

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 }

@rgwood
Copy link
Contributor

rgwood commented Aug 8, 2022

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 😅

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 8, 2022

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.

@rgwood
Copy link
Contributor

rgwood commented Aug 8, 2022

@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.

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 8, 2022

@rgwood Do you think we should add an issue on the WT repo?

@rgwood
Copy link
Contributor

rgwood commented Aug 8, 2022

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.

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 8, 2022

@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.

@rgwood
Copy link
Contributor

rgwood commented Aug 9, 2022

@fdncred Filed: microsoft/terminal#13710

@micgao
Copy link

micgao commented Aug 25, 2022

Setting "shell_integration: false" in config.nu fixes the problem

@fdncred
Copy link
Collaborator Author

fdncred commented Aug 28, 2022

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".

@NSilv
Copy link

NSilv commented Nov 3, 2022

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.

@fdncred
Copy link
Collaborator Author

fdncred commented Nov 3, 2022

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)

@rgwood
Copy link
Contributor

rgwood commented Nov 3, 2022

Nu users: if this bothers you please upvote the Windows Terminal issue

@andrei-hernandez
Copy link

Setting "shell_integration: false" in config.nu fixes the problem

Thanks, that's worked for me 🙇‍♂️

@g-berthiaume
Copy link

g-berthiaume commented Jun 15, 2023

This problem is still there as of today.
That said, setting "shell_integration: false" in config.nu did fix the flickering problem.

@fdncred
Copy link
Collaborator Author

fdncred commented Jun 15, 2023

@g-berthiaume The issue is gone in the latest Windows Terminal Preview v1.18.1462

@g-berthiaume
Copy link

Ok thanks for the update.

@bartdorsey
Copy link

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.

@bartdorsey
Copy link

Setting shell_integration false fixes WezTerm as well.

@fdncred
Copy link
Collaborator Author

fdncred commented Jul 6, 2023

@bartdorsey Yup, Wez was working on that last I checked. Trying to use the conpty that WT uses or something like that. #5585

@drguildo
Copy link

drguildo commented Jan 27, 2024

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.

@fdncred
Copy link
Collaborator Author

fdncred commented Jan 27, 2024

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.

@fdncred fdncred closed this as completed Jan 27, 2024
@drguildo
Copy link

If this is an example of a broader issue, then please redirect it to that GitHub issue.

@panicbit
Copy link
Contributor

panicbit commented Aug 1, 2024

FYI for users of recent versions of nushell:
Setting shell_integration.osc133 to false gets rid of the input buffer flickering when typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working line editor Issues related to reedline
Projects
None yet
Development

No branches or pull requests

10 participants