ghost chars when select CJK chars in vim visual mode #23095

Closed
opened 2026-01-31 08:32:14 +00:00 by claunia · 4 comments
Owner

Originally created by @DustarMao on GitHub (Mar 30, 2025).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

1.22.10731.0

Windows build number

10.0.26100.0

Other Software

vim 9.1
pwsh 7.5.0

Steps to reproduce

create a file include CJK chars like below

中文内容
にほんご

use vim open it, and select one line in visual mode

Expected Behavior

normal select line with fact chars

below is a normal result in conhost
Image

Actual Behavior

Image

display some ghost chars after end of line

Originally created by @DustarMao on GitHub (Mar 30, 2025). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version 1.22.10731.0 ### Windows build number 10.0.26100.0 ### Other Software vim 9.1 pwsh 7.5.0 ### Steps to reproduce create a file include CJK chars like below ``` 中文内容 にほんご ``` use vim open it, and select one line in visual mode ### Expected Behavior normal select line with fact chars below is a normal result in conhost ![Image](https://github.com/user-attachments/assets/1ff0968f-8137-4b3c-b717-6ccf0dcda578) ### Actual Behavior ![Image](https://github.com/user-attachments/assets/ff29ef83-cb7b-4888-8184-7dc8aa2b89e0) display some ghost chars after end of line
Author
Owner

@DustarMao commented on GitHub (Mar 30, 2025):

this bug do not appear in wt version 1.21

and i have tried 1.23, this bug also appears

@DustarMao commented on GitHub (Mar 30, 2025): this bug do not appear in wt version 1.21 and i have tried 1.23, this bug also appears
Author
Owner

@lhecker commented on GitHub (Mar 31, 2025):

Thanks for the excellent repro! When I reproduce this, I get the following output from VIM during the selection (annotated by me):

␛[?25l              # Hide cursor
␛[0 q               # Reset cursor style
␛[1;1H              # Goto the selected line of text
␛[30;31H            # Goto status bar
␛7                  # Save cursor position
␛[30;31H            # Goto status bar
␛[0m                # Reset color
1-3                  # Print status bar
␛8                  # Restore cursor position
␛7                  # Save cursor position
␛[30;31H            # Goto status bar
␛[0m                # Reset color
2-6                  # Print status bar
␛8                  # Restore cursor position
␛[30;1H             # Goto status bar
␛[30;34H            # Goto status bar
␛[30;1H             # Goto status bar
␛[1;3H              # Goto selected line of text
␛[1;1H              # Goto selected line of text
␛[1;1H              # Goto selected line of text
␛[8m                # Make text invisible
␛7                  # Save cursor position
␛[1;1H              # Goto the selected line of text
␛[0;100m            # Set selection color
中中                 <-- ⚠️ VIM prints the char twice! ⚠️
␛8                  # Restore cursor position
␛7                  # Save cursor position
␛[1;1H              # Goto the selected line of text
␛[0;100m            # Set selection color
中                   <-- ⁉️ VIM prints the char again? ⁉️
␛8                  # Restore cursor position
␛[1;1H              # Goto the selected line of text
␛[1;3H              # Goto the selected line of text
␛[0m                # Reset color
␛[7m                # Invert colors
␛[0m                # Reset color
␛[1;1H              # Goto the selected line of text
␛[30;43H            # Goto status bar
␛7                  # Save cursor position
␛[30;43H            # Goto status bar
␛[0m                # Reset color
1                    # Print status bar
␛8                  # Restore cursor position
␛7                  # Save cursor position
␛[30;43H            # Goto status bar
␛[0m                # Reset color
4-3                  # Print status bar
␛8                  # Restore cursor position
␛[30;1H             # Goto status bar
␛[30;46H            # Goto status bar
␛[30;1H             # Goto status bar
␛[1;3H              # Goto the selected line of text
␛[?25h              # Show cursor
␛[0 q               # Reset cursor style
␛[<0;3;1m           # Reset colors and then make text italic and bold
␛[?25l              # Hide cursor
␛[0 q               # Reset cursor style
␛[?25h              # Show cursor
␛[0 q               # Reset cursor style

I do have to say, it's shocking to me how "chatty" vim is. I did not expect that at all.

More importantly though, it's vim itself which prints the wide glyph twice, so it's probably not a "bug" in Windows Terminal per se (strictly speaking), but rather an unintentional regression that we may have caused with one of the recent modernizations. For instance, #16916.

Edit: Probably a fallout from pass through mode. For… reasons? vim doesn't use VT for many operations on Windows and so it may be running into an edge case when trying to insert wide glyphs into narrow cells which we forbid now.

@lhecker commented on GitHub (Mar 31, 2025): Thanks for the excellent repro! When I reproduce this, I get the following output from VIM during the selection (annotated by me): ``` ␛[?25l # Hide cursor ␛[0 q # Reset cursor style ␛[1;1H # Goto the selected line of text ␛[30;31H # Goto status bar ␛7 # Save cursor position ␛[30;31H # Goto status bar ␛[0m # Reset color 1-3 # Print status bar ␛8 # Restore cursor position ␛7 # Save cursor position ␛[30;31H # Goto status bar ␛[0m # Reset color 2-6 # Print status bar ␛8 # Restore cursor position ␛[30;1H # Goto status bar ␛[30;34H # Goto status bar ␛[30;1H # Goto status bar ␛[1;3H # Goto selected line of text ␛[1;1H # Goto selected line of text ␛[1;1H # Goto selected line of text ␛[8m # Make text invisible ␛7 # Save cursor position ␛[1;1H # Goto the selected line of text ␛[0;100m # Set selection color 中中 <-- ⚠️ VIM prints the char twice! ⚠️ ␛8 # Restore cursor position ␛7 # Save cursor position ␛[1;1H # Goto the selected line of text ␛[0;100m # Set selection color 中 <-- ⁉️ VIM prints the char again? ⁉️ ␛8 # Restore cursor position ␛[1;1H # Goto the selected line of text ␛[1;3H # Goto the selected line of text ␛[0m # Reset color ␛[7m # Invert colors ␛[0m # Reset color ␛[1;1H # Goto the selected line of text ␛[30;43H # Goto status bar ␛7 # Save cursor position ␛[30;43H # Goto status bar ␛[0m # Reset color 1 # Print status bar ␛8 # Restore cursor position ␛7 # Save cursor position ␛[30;43H # Goto status bar ␛[0m # Reset color 4-3 # Print status bar ␛8 # Restore cursor position ␛[30;1H # Goto status bar ␛[30;46H # Goto status bar ␛[30;1H # Goto status bar ␛[1;3H # Goto the selected line of text ␛[?25h # Show cursor ␛[0 q # Reset cursor style ␛[<0;3;1m # Reset colors and then make text italic and bold ␛[?25l # Hide cursor ␛[0 q # Reset cursor style ␛[?25h # Show cursor ␛[0 q # Reset cursor style ``` I do have to say, it's shocking to me how "chatty" vim is. I did not expect that at all. More importantly though, it's vim itself which prints the wide glyph twice, so it's probably not a "bug" in Windows Terminal per se (strictly speaking), but rather an unintentional regression that we may have caused with one of the recent modernizations. For instance, #16916. Edit: Probably a fallout from pass through mode. For… reasons? vim doesn't use VT for many operations on Windows and so it may be running into an edge case when trying to insert wide glyphs into narrow cells which we forbid now.
Author
Owner

@DustarMao commented on GitHub (Apr 1, 2025):

vim doesn't use VT for many operations on Windows and so it may be running into an edge case when trying to insert wide glyphs into narrow cells which we forbid now.

is there any setting to prevent this issue in current version?

@DustarMao commented on GitHub (Apr 1, 2025): > vim doesn't use VT for many operations on Windows and so it may be running into an edge case when trying to insert wide glyphs into narrow cells which we forbid now. is there any setting to prevent this issue in current version?
Author
Owner

@lhecker commented on GitHub (Apr 2, 2025):

is there any setting to prevent this issue in current version?

Unfortunately not. You can only either use vim through MSYS2 or through WSL. Otherwise, you can of course downgrade to 1.21 for the time being.

@lhecker commented on GitHub (Apr 2, 2025): > is there any setting to prevent this issue in current version? Unfortunately not. You can only either use vim through MSYS2 or through WSL. Otherwise, you can of course downgrade to 1.21 for the time being.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23095