microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.2k stars 8.27k forks source link

Cursor position is wrong after exiting vim #16254

Open tcx4c70 opened 11 months ago

tcx4c70 commented 11 months ago

Windows Terminal version

1.18.2822.0

Windows build number

10.0.22631.0

Other Software

vim 9.0.2081 (installed via scoop) Power Shell 7.3.9

Steps to reproduce

  1. Make sure your monitor can display >60 lines in Windows Terminal.
  2. Move cursor to the end of the monitor by entering Enter :)
  3. vim -u NONE test.txt to open vim then exit.

https://github.com/microsoft/terminal/assets/16728230/0e5f2549-4caf-458c-a0f4-59c72fe617d5

It can't be reproduced if I use pwsh7 directly (without Windows Terminal), so maybe it's a problem of Windows Terminal?

Expected Behavior

After exiting vim, the cursor should be at the last line of the monitor.

Actual Behavior

After exiting vim, the cursor is in the middle of the monitor (~60th line). And cls will not clear the bottom half of the monitor.

zadjii-msft commented 11 months ago

Just to be sure - is that PowerShell 7? The tab does say "Windows PowerShell", which makes me think that it's powershell 5 (powershell.exe).

I wonder if the PSReadline version has something to do with it? FWIW, I can repro something similar (on 1.20), but slightly different. For me, vim opens only on the top half, then when I exit, everything's still in the right place, but like half the output is cleared

image

image

tcx4c70 commented 11 months ago

Just to be sure - is that PowerShell 7? The tab does say "Windows PowerShell", which makes me think that it's powershell 5 (powershell.exe).

Yes, it's PowerShell 7. I have changed the command line of "Windows PowerShell" to pwsh7 manually.

DHowett commented 11 months ago

We were about to say this was a vim-specific issue, but... it doesn't reproduce in the traditional Windows console host. :thinking:

zadjii-msft commented 10 months ago

See https://github.com/MicrosoftDocs/Console-Docs/issues/302

I can't find any reference to MaxPhysicalWindowSize in the console docs, I may be missing something, but is there a way to set this value?

The initial COORD in CreatePseudoConsole and in ResizePseudoConsole seem to only take X/Y.

Some programs like vim and other use it as upper bound. Upon exit, it restores the terminal modes and size, which results in the wrong one, breaking the terminal.

emph added