Vim output getting skewed and duplicated chaotically when increasing the font size or resizing the window #10086

Closed
opened 2026-01-31 02:12:08 +00:00 by claunia · 9 comments
Owner

Originally created by @Tompouce-onGit on GitHub (Aug 10, 2020).

Originally assigned to: @DHowett on GitHub.

Environment

Windows build number: 10.0.18363.0
Windows Terminal version (if applicable): 1.1.2021.0

Any other software?
Vim, version 8.1

Steps to reproduce

Open Windows Terminal and, in a powershell tab, launch vim with a file containing text.
Change the font size with CTRL+MouseWheelScroll.
Resize the terminal window by draging one of the sides.

Expected behavior

The output of vim should stay stable, i.e. simply get bigger or smaller, with CTRL+MouseWheelScroll, and not budge when resizing the window.

Actual behavior

As the title implies, the output gets skewed and spread over the screen in a chaotic fashion, lines fall out of allignment with each other and get duplicated upwards when resizing the font ; resizing the windows after that does the same. This is illustrated in this mp4 screen capture (I had troubles recording a gif, so I had to make an mp4 file).

Note that, right after starting vim, resizing the windows does not affect the output the same way if the font size was not changed with CTRL+MouseWheelScroll before. Instead, as the window is being resized, the lines flicker as they get dragged horizontally accross the window. When the resizing motion is stopped, they fall back into their intended positions and the output stabilizes, but lines of the file still get duplicated above chaoticaly, which can be seen by scrolling up. This is illustrated in this mp4 screen capture.

This is an issue with the display of the text output when using vim, I have not tested it with other software, and while the displayed text gets skewed and duplicated, the actual contents of the file being viewed don't get modified by this.

Finaly, note that the abnormal behaviours described above do not occur in a regular powershell window, i.e. an instance of powershell created with the powershell start menu icon. They only occur in Windows Terminal.

Originally created by @Tompouce-onGit on GitHub (Aug 10, 2020). Originally assigned to: @DHowett on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18363.0 Windows Terminal version (if applicable): 1.1.2021.0 Any other software? Vim, version 8.1 ``` # Steps to reproduce Open Windows Terminal and, in a powershell tab, launch vim with a file containing text. Change the font size with CTRL+MouseWheelScroll. Resize the terminal window by draging one of the sides. # Expected behavior The output of vim should stay stable, i.e. simply get bigger or smaller, with CTRL+MouseWheelScroll, and not budge when resizing the window. # Actual behavior As the title implies, the output gets skewed and spread over the screen in a chaotic fashion, lines fall out of allignment with each other and get duplicated upwards when resizing the font ; resizing the windows after that does the same. This is illustrated in [this](https://imgur.com/a/SX25111) mp4 screen capture (I had troubles recording a gif, so I had to make an mp4 file). Note that, right after starting vim, resizing the windows does not affect the output the same way if the font size was not changed with CTRL+MouseWheelScroll before. Instead, as the window is being resized, the lines flicker as they get dragged horizontally accross the window. When the resizing motion is stopped, they fall back into their intended positions and the output stabilizes, but lines of the file still get duplicated above chaoticaly, which can be seen by scrolling up. This is illustrated in [this](https://imgur.com/a/M695jOz) mp4 screen capture. This is an issue with the display of the text output when using vim, I have not tested it with other software, and while the displayed text gets skewed and duplicated, the actual contents of the file being viewed don't get modified by this. Finaly, note that the abnormal behaviours described above do *not* occur in a regular powershell window, i.e. an instance of powershell created with the powershell start menu icon. They only occur in Windows Terminal.
claunia added the Issue-BugResolution-DuplicateProduct-Terminal labels 2026-01-31 02:12:09 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Aug 10, 2020):

That's bizarre, it looks almost as if vim.exe isn't getting the buffer size changed event.

@DHowett is usually our go-to vim guy, I wonder if he's seen this

@zadjii-msft commented on GitHub (Aug 10, 2020): That's bizarre, it looks almost as if `vim.exe` isn't getting the buffer size changed event. @DHowett is usually our go-to `vim` guy, I wonder if he's seen this
Author
Owner

@Tompouce-onGit commented on GitHub (Aug 10, 2020):

That's bizarre, it looks almost as if vim.exe isn't getting the buffer size changed event.

Yes, I was getting the impression that vim was not noticing the change in the window size.

Also just for info, I tried repairing the app in the app settings for Windows terminal, and also uninstalling it then re-installing it from the windows store ; the issue persisted after both attempts.

@Tompouce-onGit commented on GitHub (Aug 10, 2020): > That's bizarre, it looks almost as if `vim.exe` isn't getting the buffer size changed event. Yes, I was getting the impression that vim was not noticing the change in the window size. Also just for info, I tried repairing the app in the app settings for Windows terminal, and also uninstalling it then re-installing it from the windows store ; the issue persisted after both attempts.
Author
Owner

@Axedyson commented on GitHub (Aug 14, 2020):

I have the exact same problem. I would also like to add another issue with using vim in Windows Terminal (it doesn't happen in a regular windows command prompt) hope it could help:
https://imgur.com/a/EzXaXyc (Sorry that I didn't record my screen better)

@Axedyson commented on GitHub (Aug 14, 2020): I have the exact same problem. I would also like to add another issue with using vim in Windows Terminal (it doesn't happen in a regular windows command prompt) hope it could help: https://imgur.com/a/EzXaXyc (Sorry that I didn't record my screen better)
Author
Owner

@zadjii-msft commented on GitHub (Aug 14, 2020):

@AndysonDK that's actually already tracked by #3848

@zadjii-msft commented on GitHub (Aug 14, 2020): @AndysonDK that's actually already tracked by #3848
Author
Owner

@Axedyson commented on GitHub (Aug 14, 2020):

@zadjii-msft Oh okay, thanks for notifying me!

@Axedyson commented on GitHub (Aug 14, 2020): @zadjii-msft Oh okay, thanks for notifying me!
Author
Owner

@waf commented on GitHub (Aug 16, 2020):

I'm able to reproduce the issue stated in the original description, with the following reproduction steps. Reproduces every time in both PowerShell 5 and PowerShell 7. It does not reproduce in conhost.

  • Run vim --clean -- this is like a "safe mode" and removes any vimrc or plugins to make the repro more simple
  • Resize the terminal
  • Close vim
  • Run vim --clean again
  • Output is skewed, especially if you cause vim to redraw / scroll

As a side note, if you use the following options in _vimrc it will be garbled on initial startup, I guess because it triggers the resize. Conhost will resize the physical window, but Windows Terminal does not resize.

set lines=30
set columns=100

Vim version is 8.2.1424

@waf commented on GitHub (Aug 16, 2020): I'm able to reproduce the issue stated in the original description, with the following reproduction steps. Reproduces every time in both PowerShell 5 and PowerShell 7. It does not reproduce in conhost. - Run `vim --clean` -- this is like a "safe mode" and removes any vimrc or plugins to make the repro more simple - Resize the terminal - Close vim - Run `vim --clean` again - Output is skewed, especially if you cause vim to redraw / scroll As a side note, if you use the following options in _vimrc it will be garbled on initial startup, I guess because it triggers the resize. Conhost will resize the physical window, but Windows Terminal does not resize. ```viml set lines=30 set columns=100 ``` Vim version is 8.2.1424
Author
Owner

@DHowett commented on GitHub (Aug 19, 2020):

Okay, at its core @waf's report is very related to #5094... but it's a little more complicated than that. Vim for Windows start up and immediately saves everything it can possibly find out about the console. That includes a number of user-preference things like how big the window is.

On exit, it restores the window size.

Terminal doesn't support window size changes initiated by client applications.

@Tompouce-onGit's report is a different beast.

Finaly, note that the abnormal behaviours described above do not occur in a regular powershell window, i.e. an instance of powershell created with the powershell start menu icon. They only occur in Windows Terminal.

This definitely reproduces in a traditional conhost window for me. It just happens faster, and vim itself deletes the text that goes off the top of the screen.

This is because we try to reflow the contents of the buffer as you resize. The text on the screen (vim's ~s) gets line wrapped over and over and over as you make the window smaller and vim compensates for the new size by redrawing everything.

I've noticed that other terminal emulators do not do wrapping when the alternate buffer is in use. If we do the same thing, that will fix WSL vim . . . but it will not fix Windows vim, because they are not using alternate buffers.

This one's going to be impossible for us to fix without vim doing a bit of legwork on Windows to ensure the proper behavior.

@DHowett commented on GitHub (Aug 19, 2020): Okay, at its core @waf's report is very related to #5094... but it's a little more complicated than that. Vim for Windows start up and _immediately saves everything it can possibly find out_ about the console. That includes a number of user-preference things like _how big the window is_. On exit, it restores the window size. Terminal doesn't support window size changes initiated by client applications. @Tompouce-onGit's report is a different beast. > Finaly, note that the abnormal behaviours described above do not occur in a regular powershell window, i.e. an instance of powershell created with the powershell start menu icon. They only occur in Windows Terminal. This definitely reproduces in a traditional conhost window for me. It just happens _faster_, and vim itself deletes the text that goes off the top of the screen. This is because we try to reflow the contents of the buffer as you resize. The text on the screen (vim's `~`s) gets line wrapped over and over and over as you make the window smaller and vim compensates for the new size by redrawing everything. I've noticed that other terminal emulators _do not do wrapping_ when the alternate buffer is in use. If we do the same thing, that will fix WSL vim . . . but it will not fix Windows vim, because they are not using alternate buffers. This one's going to be impossible for us to fix without vim doing a bit of legwork on Windows to ensure the proper behavior.
Author
Owner

@zadjii-msft commented on GitHub (Aug 19, 2020):

Thanks for clearing that up Dustin. In my opinion, this sounds like the combo of:

is about as good as we're going to be able to do on this one. So I'm gonna close this as a collective dupe of all those threads. Thanks for the investigation guys!

/dup #381
/dup #5094
/dup #3493

@zadjii-msft commented on GitHub (Aug 19, 2020): Thanks for clearing that up Dustin. In my opinion, this sounds like the combo of: * Fixing #5094 * Implementing support for the alt buffer: #381 * and also doing "Consider not wrapping the alternate screen on resize #3493" is about as good as we're going to be able to do on this one. So I'm gonna close this as a collective dupe of all those threads. Thanks for the investigation guys! /dup #381 /dup #5094 /dup #3493
Author
Owner

@ghost commented on GitHub (Aug 19, 2020):

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 (Aug 19, 2020): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10086