Windows-Terminal with vim keeping UTF chars when open/close #12479

Closed
opened 2026-01-31 03:16:49 +00:00 by claunia · 6 comments
Owner

Originally created by @iguyking on GitHub (Feb 9, 2021).

Environment

Windows build number: 10.0.19042.0
Windows Terminal version (if applicable):  1.5.210127001-release1.5
Starship:  0.50.0
Powershell Core: 7.1.1

Any other software?

Steps to reproduce

  1. Setup Windows Powershell with a valid Powerline capable font and run the starship.rs prompt where it loads terraform or other special modules showing UTF characters in the prompt.
  2. Launch Windows Terminal with a Powershell Session
  3. change into a directory that triggers this complex UTF character to show up on the prompt
  4. Launch vim, close vim
  5. The previous prompts above no longer show the proper characters and the layout is confused. Example: 💠 character.

Red shows the previous - re-rendered incorrectly after exiting vim
Yellow shows a new line.

image

Expected behavior

When leaving vim I would expect to see the same layout as I left.

Actual behavior

The layout is adjusted oddly after leaving vim that were previously displayed properly.

Originally created by @iguyking on GitHub (Feb 9, 2021). # Environment ```none Windows build number: 10.0.19042.0 Windows Terminal version (if applicable): 1.5.210127001-release1.5 Starship: 0.50.0 Powershell Core: 7.1.1 Any other software? ``` # Steps to reproduce 1. Setup Windows Powershell with a valid Powerline capable font and run the starship.rs prompt where it loads terraform or other special modules showing UTF characters in the prompt. 2. Launch Windows Terminal with a Powershell Session 3. change into a directory that triggers this complex UTF character to show up on the prompt 4. Launch vim, close vim 5. The previous prompts above no longer show the proper characters and the layout is confused. Example: 💠 character. Red shows the previous - re-rendered incorrectly after exiting vim Yellow shows a new line. ![image](https://user-images.githubusercontent.com/5004028/107407930-e7859d00-6acf-11eb-8d9e-d41578412a3e.png) # Expected behavior When leaving vim I would expect to see the same layout as I left. # Actual behavior The layout is adjusted oddly after leaving vim that were previously displayed properly.
Author
Owner

@DHowett commented on GitHub (Feb 9, 2021):

Red: Do you have vim configured to change the side of the terminal/console window using set lines or set columns?

Yellow: yup, sorry, this is just how it works. Vim for Windows takes a full copy of the entire screen and then when it exits, dumps it back out to the screen. In so doing, it corrupts all characters that do not fit in a single UCS-2 code unit. Vim for Windows could have been using an "alternate screen" (which we have supported for 26 years) instead of doing this, but they are not.

@DHowett commented on GitHub (Feb 9, 2021): Red: Do you have vim configured to change the side of the terminal/console window using `set lines` or `set columns`? Yellow: yup, sorry, this is just how it works. Vim for Windows _takes a full copy of the entire screen_ and then when it exits, dumps it back out to the screen. In so doing, it corrupts all characters that do not fit in a single UCS-2 code unit. Vim for Windows could have been using an "alternate screen" (which we have supported for 26 years) instead of doing this, but they are not.
Author
Owner

@iguyking commented on GitHub (Feb 9, 2021):

@DHowett Nope.. The Red is part that shows up AFTER you leave vim. That explains it.

Your answer to Yellow explains that. I have something to bring back to the vim team now in the ticket I have open with them.

@iguyking commented on GitHub (Feb 9, 2021): @DHowett Nope.. The Red is part that shows up AFTER you leave vim. That explains it. Your answer to Yellow explains that. I have something to bring back to the vim team now in the ticket I have open with them.
Author
Owner

@iguyking commented on GitHub (Feb 9, 2021):

This is what it looks like normally when I'm using Windows Terminal.

image

The screen shot in the opening ticket is what it looks like when I exit vim for windows.

@iguyking commented on GitHub (Feb 9, 2021): This is what it looks like normally when I'm using Windows Terminal. ![image](https://user-images.githubusercontent.com/5004028/107434845-eca71400-6af0-11eb-843a-a35c0af77300.png) The screen shot in the opening ticket is what it looks like when I exit vim for windows.
Author
Owner

@k-takata commented on GitHub (Feb 10, 2021):

Vim for Windows could have been using an "alternate screen" (which we have supported for 26 years) instead of doing this, but they are not.

Vim had tried to use CreateConsoleScreenBuffer/SetConsoleActiveScreenBuffer in 7.4.851 and also on Vim6.
But there were some issues with 3rd party terminals:
https://groups.google.com/g/vim_dev/c/ZSklyGjhUAw/m/1_Nqe_fUAAAJ
So, it was reverted.

@k-takata commented on GitHub (Feb 10, 2021): > Vim for Windows could have been using an "alternate screen" (which we have supported for 26 years) instead of doing this, but they are not. Vim had tried to use CreateConsoleScreenBuffer/SetConsoleActiveScreenBuffer in 7.4.851 and also on Vim6. But there were some issues with 3rd party terminals: https://groups.google.com/g/vim_dev/c/ZSklyGjhUAw/m/1_Nqe_fUAAAJ So, it was reverted.
Author
Owner

@DHowett commented on GitHub (Feb 10, 2021):

@k-takata ah, thanks for the information! I wasn't aware that ConsoleZ didn't handle this correctly.

Versions of Telnet that ship with newer versions of Windows handle this more correctly, as does sshd (the version that comes with windows.) We have much better support for the xterm alternate buffer as well -- perhaps that would be a reasonable thing to use on newer versions of Windows? I'd gladly attempt to implement that myself. 😄

@DHowett commented on GitHub (Feb 10, 2021): @k-takata ah, thanks for the information! I wasn't aware that ConsoleZ didn't handle this correctly. Versions of Telnet that ship with newer versions of Windows handle this more correctly, as does sshd (the version that comes with windows.) We have much better support for the xterm alternate buffer as well -- perhaps that would be a reasonable thing to use on newer versions of Windows? I'd gladly attempt to implement that myself. :smile:
Author
Owner

@DHowett commented on GitHub (Feb 12, 2021):

Closing this one out as external. Sorry all!

@DHowett commented on GitHub (Feb 12, 2021): Closing this one out as external. Sorry all!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12479