VIM Screen Corruption #17871

Closed
opened 2026-01-31 05:56:53 +00:00 by claunia · 6 comments
Owner

Originally created by @EnGamma on GitHub (Jul 6, 2022).

Windows Terminal version

1.13.11431.0

Windows build number

10.0.19043.1766

Other Software

vim 8.2 in Windows Terminal WSL (both Ubuntu and Debian variants)

Debian:
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 01 2021 01:51:08)
Included patches: 1-2434
Extra patches: 8.2.3402, 8.2.3403, 8.2.3409, 8.2.3428

Ubuntu:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32)
Included patches: 1-2269, 3612, 3625, 3669, 3741

vimrc.txt

Steps to reproduce

Start VIM, look to bottom of screen, see that the tail of the VIM status bar text is wrapped to the next screen line.

Alternatively, have VIM open a new file or a file of only a few lines that will not fill the screen vertically with lines. The normally line-leading tildes ~ are scattered across the screen instead of at the left edge [note that this happens only in a non-full-screen window. In full screen it appears normal.]

vim_newfile
.

Expected Behavior

Windows Terminal => VIM screen width communicated reliably at startup, no wrapping of status bar, no further corruption as scrolling causes more of the wrapped text to fill bottom of screen, no misalignment of visible line text with underlying line #.

Actual Behavior

I'm seeing screen corruption with VIM in Windows Terminal (WT) immediately upon startup of VIM and am NOT using tmux. I've determined that it has something to do with VIM not getting the proper screen width from WT. The most obvious indicator that this is happening is that the tail end of the VIM status bar get's wrapped to an added screen line. For example, the tail end of the status bar might indicate the cursor is on line 141, column 1, 74% through the file with this at the tail end: "141,1 74%". What happens is "41,1 74%" gets wrapped to a new line on the screen. Any scrolling causes more wrapping lines to appear at the bottom of the WT window.

Also, if editing a file of only a few lines, VIM fills the screen below with lines starting with a tilde ~. If you open such a file, the ~ are scattered across the screen.

The corruption seems to persist even after exiting back to shell prompt (i.e., the shell prompt is invisible after a ^L and becomes visible again only after pressing [ENTER]).

I've found 2 cumbersome workarounds for now:

Resize the terminal widow or
Toggle full screen [F11] [F11] or [ALT]-{ENTER] [ALT]-[ENTER]
Performance is normal after that.

Originally created by @EnGamma on GitHub (Jul 6, 2022). ### Windows Terminal version 1.13.11431.0 ### Windows build number 10.0.19043.1766 ### Other Software vim 8.2 in Windows Terminal WSL (both Ubuntu and Debian variants) Debian: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 01 2021 01:51:08) Included patches: 1-2434 Extra patches: 8.2.3402, 8.2.3403, 8.2.3409, 8.2.3428 Ubuntu: VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Included patches: 1-2269, 3612, 3625, 3669, 3741 [vimrc.txt](https://github.com/microsoft/terminal/files/9056483/vimrc.txt) ### Steps to reproduce Start VIM, look to bottom of screen, see that the tail of the VIM status bar text is wrapped to the next screen line. Alternatively, have VIM open a new file or a file of only a few lines that will not fill the screen vertically with lines. The normally line-leading tildes ~ are scattered across the screen instead of at the left edge [note that this happens only in a non-full-screen window. In full screen it appears normal.] ![vim_newfile](https://user-images.githubusercontent.com/10820881/177599298-7e85e943-2226-421f-afbb-6a165e606863.png) . ### Expected Behavior Windows Terminal => VIM screen width communicated reliably at startup, no wrapping of status bar, no further corruption as scrolling causes more of the wrapped text to fill bottom of screen, no misalignment of visible line text with underlying line #. ### Actual Behavior I'm seeing screen corruption with VIM in Windows Terminal (WT) immediately upon startup of VIM and am NOT using tmux. I've determined that it has something to do with VIM not getting the proper screen width from WT. The most obvious indicator that this is happening is that the tail end of the VIM status bar get's wrapped to an added screen line. For example, the tail end of the status bar might indicate the cursor is on line 141, column 1, 74% through the file with this at the tail end: "141,1 74%". What happens is "41,1 74%" gets wrapped to a new line on the screen. Any scrolling causes more wrapping lines to appear at the bottom of the WT window. Also, if editing a file of only a few lines, VIM fills the screen below with lines starting with a tilde ~. If you open such a file, the ~ are scattered across the screen. The corruption seems to persist even after exiting back to shell prompt (i.e., the shell prompt is invisible after a ^L and becomes visible again only after pressing [ENTER]). I've found 2 cumbersome workarounds for now: Resize the terminal widow or Toggle full screen [F11] [F11] or [ALT]-{ENTER] [ALT]-[ENTER] Performance is normal after that.
claunia added the Help WantedIssue-BugArea-VTResolution-DuplicatePriority-2 labels 2026-01-31 05:56:54 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2022):

Wow okay there's like, a LOT going on wrong when I use that vimrc 😨 I'm seeing way worse artifacts than just the screen size being wrong. Hopefully there's just one sequence that's causing all the corruption here.

Interestingly though, I think that opening that vimrr in vim, then exiting, does seemingly resize the conpty buffer. Opening nano after closing vim looks equally crazy:
image

@zadjii-msft commented on GitHub (Jul 7, 2022): Wow okay there's like, a LOT going on wrong when I use that vimrc 😨 I'm seeing way worse artifacts than just the screen size being wrong. Hopefully there's just one sequence that's causing all the corruption here. Interestingly though, I think that opening that vimrr in vim, then exiting, does seemingly resize the conpty buffer. Opening nano after closing vim looks equally crazy: ![image](https://user-images.githubusercontent.com/18356694/177756984-1e50beee-19d0-4fa0-ad97-290ab2d7c07d.png)
Author
Owner

@j4james commented on GitHub (Jul 7, 2022):

I think the issue here is just that you've configured VIM to request a specific screen size, and Windows Terminal doesn't support that. It looks fine to me if I comment out this line:

set lines=72 columns=269

Unless there is some other problem that I'm missing, this looks to me like a duplicate of #5094.

@j4james commented on GitHub (Jul 7, 2022): I think the issue here is just that you've configured VIM to request a specific screen size, and Windows Terminal doesn't support that. It looks fine to me if I comment out this line: set lines=72 columns=269 Unless there is some other problem that I'm missing, this looks to me like a duplicate of #5094.
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2022):

That's exactly it.

/dup #5094

@zadjii-msft commented on GitHub (Jul 7, 2022): That's exactly it. /dup #5094
Author
Owner

@ghost commented on GitHub (Jul 7, 2022):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jul 7, 2022): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@EnGamma commented on GitHub (Jul 7, 2022):

Thank you, fix confirmed on my system. Do you know if there is a way for
VIM to detect Windows Terminal so that I can make that setting conditional?

@EnGamma commented on GitHub (Jul 7, 2022): Thank you, fix confirmed on my system. Do you know if there is a way for VIM to detect Windows Terminal so that I can make that setting conditional?
Author
Owner

@hulucc commented on GitHub (Jul 21, 2022):

if !empty($WT_SESSION)
    ...
 endif
@hulucc commented on GitHub (Jul 21, 2022): ```s if !empty($WT_SESSION) ... endif ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17871