Terminal: Vim output getting skewed and duplicated chaotically when increasing the font size or resizing the window

Created on 10 Aug 2020  路  9Comments  路  Source: microsoft/terminal

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.

Issue-Bug Product-Terminal Resolution-Duplicate

All 9 comments

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

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.

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)

@AndysonDK that's actually already tracked by #3848

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

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

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.

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

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!

Was this page helpful?
0 / 5 - 0 ratings