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

Weird blue selection after closing neovim (WSL) #3848

Closed
schffp opened this issue Dec 5, 2019 · 15 comments · Fixed by #5792
Closed

Weird blue selection after closing neovim (WSL) #3848

schffp opened this issue Dec 5, 2019 · 15 comments · Fixed by #5792
Assignees
Labels
Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@schffp
Copy link

schffp commented Dec 5, 2019

Environment

Windows build number: Microsoft Windows Version 10.0.18362.476
Windows Terminal version: microsoft-windows-terminal 0.7.3291.0

Steps to reproduce

  1. Open terminal in wsl mode
  2. Open neovim
  3. Resize the window
  4. Quit neovim

Actual behavior

A weird blue "selection" appears
clear gets rid of it

blue

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Dec 5, 2019
@DHowett-MSFT DHowett-MSFT added Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Dec 5, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Dec 5, 2019
@DHowett-MSFT DHowett-MSFT added the Help Wanted We encourage anyone to jump in on these. label Dec 5, 2019
@DHowett-MSFT DHowett-MSFT added this to the Terminal Backlog milestone Dec 5, 2019
@DHowett-MSFT
Copy link
Contributor

I bet @j4james has an inkling as to what's happening here 😁

@j4james
Copy link
Collaborator

j4james commented Dec 5, 2019

I was just looking at this, because I thought I knew what it was, but I'm not so sure now. 😄 I thought it might be related to #2540, but I can't reproduce this exact scenario.

A couple of questions for @schffp:

  1. When you say "open terminal in WSL mode", what exactly does that mean? That screenshot doesn't look like the new Windows Terminal app, but then again it doesn't look like the old conhost shell either, so I'm not sure what it is.
  2. Do you have to run vim to reproduce the problem? I know resizing the window can do some weird things to the background colors, but the problems I know off wouldn't require that you run vim to trigger the issue.
  3. Have you customised the default colors, the color palette, or anything like that?

@schffp
Copy link
Author

schffp commented Dec 5, 2019

@j4james

  1. It's the new Windows Terminal, I just have it set to open WSL/Ubuntu as default and disabled the tab bar.
  2. You have to run neovim to be specific. I just tried it vim and nano and I couldn't reproduce this exact bug with those. I've found something else though. If you ls -lah then enter vim/nano, then resize, then exit vim/nano, the 777 background color stretches over the whole terminal width. I've attached a screenshot.
  3. I've customized the background color to match my neovim color scheme. The terminal color scheme is Campbell (which I believe is default).

PS: I've just cleared out my whole nvim config file. Same bug, but the "selection" is white now.

vim

@j4james
Copy link
Collaborator

j4james commented Dec 5, 2019

@schffp Thanks for those details. I can reproduce it now.

The green bars are a known issue (#32). And I think #293 and/or #2661 may have something to do with the exact colors you're seeing. But I need to do a bit more digging to find out what is going on with the nvim resizing side of things. That may be something new.

@j4james
Copy link
Collaborator

j4james commented Dec 6, 2019

Just a quick status update before I go to sleep. #2540 is partly to blame, and fixing that should address this issue too, but that's really just covering up a deeper problem. Namely that a resize operation fills the lower part of the buffer with the active attributes, which I'm pretty sure is wrong.

And it's possible #399 may be a related issue - if not the same - although I haven't had a chance to look at that in much detail yet.

@DHowett-MSFT
Copy link
Contributor

@j4james thanks for digging into this 😄 we really appreciate it

@j4james
Copy link
Collaborator

j4james commented Dec 8, 2019

The short answer to this is you need to use the default attributes (i.e. TextAttribute{}) in place of GetAttributes() when initialising the new text buffer when resizing.

The long answer is more complicated. Sometimes the initial buffer is initialized as legacy white on black, rather than the default colors, and in those circumstances it would be more correct for the resize to use those same colors. And in theory, it's possible that the forward buffer could be filled with a whole range of different colors, in which case the resize should really be trying to preserve those colors in whatever way makes the most sense for a reflow (at the very least that should be done for the visible viewport). And anything not covered by that reflow should probably use the same colors as the bottom right corner (of the buffer, not the viewport).

99% of the time, though, the default attributes are going to be the right choice, so that's at least a reasonable short-term improvement.

@s10g
Copy link

s10g commented Feb 26, 2020

Just a tidbit related to this. When I run neovim, neovim will change the cursor from WT-set "vintage" to neovim-set block cursor (filledRectangle?). When exiting neovim, cursor stays as block cursor instead of returning to vintage cursor.

After having started and exited neovim to produce this "lingering" block cursor, the terminal starts doing weird things; the closest I could describe it as is that some escape sequences are lingering and not cleaned up properly.

I don't know where the fault lies, but at least this neovim-setting seems to fix it for now, which tells neovim to not change the cursor shape at all:
set guicursor=

@jdebp
Copy link

jdebp commented Feb 27, 2020

That's two other, different, issues: #3684 and #1604.

@jazzdelightsme
Copy link
Member

Another potential repro:

When pwsh is out-of-date, it prints out a "hey you should get the new one" banner when it starts (the banner has a different background). If I double-click Terminal’s title bar to maximize it at juuuuust the right time while it is starting, I get some funky spillage of the background color:

image

If I then “restore” the window, everything goes back to normal. And then if I maximize again, it doesn’t go back to the funky view—it still looks normal.

@mingsxs
Copy link

mingsxs commented Apr 20, 2021

Sorry but this issue still exists in the latest build, and this issue can be really annoying, it will be very grateful that it can be fixed in next release......

@zadjii-msft
Copy link
Member

Sorry, but I don't have the time this month to loop back on #5792 and do the due diligence to make sure that's the right fix. Usually I'd trust @j4james for help with those sorts of things, he might be able to give me a sanity check. Maybe we could just toss that in (before the bug bash friday...? @DHowett) and see how it feels. Less risky now that we're in the 2.0 "break everything" phase rather than the high-bar-for-1.0-release phase. It's been just about a year since I authored that PR so I don't really have the context anymore, unfortunately.

@j4james
Copy link
Collaborator

j4james commented Apr 20, 2021

I'm still not in a position where I can do any real testing, but I believe PR #5792 is the right move. I was initially somewhat concerned (back in 2019) that the buffer should be initialized with white on black in some cases, but that was addressed in PR #6698, so all shells should be initializing with default attributes now.

@ghost ghost closed this as completed in #5792 Apr 21, 2021
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Apr 21, 2021
ghost pushed a commit that referenced this issue Apr 21, 2021
…5792)

When we resize the text buffer, initialize the buffer with the
_default_¹ attributes, not the _current_ ones. If we use the current
attributes, then we can get into scenarios where something like `vim` is
running, and left the attributes set to something other than the
defaults, and when we resized the buffer, we'd fill it up with color, as
opposed to whatever the default would be.

This PR instead initializes the buffers with the default colors. It also
makes sure to set the active attributes of the newly created buffers
back to whatever the current attributes of the old buffer were.

[1]: For the Terminal, the default attributes are "default on default".
For conhost, the default attributes are whatever the result of
`Settings::GetDefaultAttributes` is, which could be any combo of the
legacy indices and the default color.

## PR Checklist
* [x] Closes #3848
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed
* ran tests
@mingsxs
Copy link

mingsxs commented May 11, 2021

Sorry for the late reply, it's okay, I commented on this issue just for your awareness since this issue could really impact us as users.

@ghost
Copy link

ghost commented May 25, 2021

🎉This issue was addressed in #5792, which has now been successfully released as Windows Terminal Preview v1.9.1445.0.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants