Skip to content

Fix wide character display with popups#19271

Open
mattn wants to merge 3 commits intovim:masterfrom
mattn:fix-popup-wide-char-display
Open

Fix wide character display with popups#19271
mattn wants to merge 3 commits intovim:masterfrom
mattn:fix-popup-wide-char-display

Conversation

@mattn
Copy link
Member

@mattn mattn commented Jan 29, 2026

Problem

When a popup window partially overlaps a wide character (e.g., Japanese characters):

  1. Truncated display: If only the right half of a wide character is visible, the character was displayed with its right half cut off, violating Vim's rule that "wide characters with only half visible should not be shown at all."

  2. Garbage display: Old character data remained in the screen buffer and was visible through the popup, appearing as garbage.

Reproduction

call setline(1, 'This is line 1')
call setline(2, 'あいうえお')
call setline(3, '        かきくけこ')
hi MyPopup guibg=darkblue guifg=white
call popup_create(['FOO  BAR'], #{
\ line: 1,
\ col: 2,
\ minwidth: 15,
\ minheight: 3,
\ highlight: 'MyPopup',
\})

Before: The first character "あ" in line 2 shows only its left half (truncated). When adding spaces to line 3, garbage appears where the right half of "け" would be.

After: Characters are completely hidden when partially overlapped, and no garbage appears.

image

Left half of あ must not be shown.

image

Right half of "け" must be shown as a space.

Solution

In screen.c, when rendering wide characters that are partially blocked by a popup:

  • Clear both cells of the wide character in ScreenLines to prevent garbage
  • Only draw the cells that are not blocked by the popup
  • Skip drawing the entire wide character (set redraw_this = FALSE)

@mattn mattn force-pushed the fix-popup-wide-char-display branch from a870436 to 813da06 Compare January 29, 2026 08:57
@vim-ml
Copy link

vim-ml commented Jan 29, 2026 via email

@mattn mattn force-pushed the fix-popup-wide-char-display branch from 813da06 to ce5fdd7 Compare January 30, 2026 10:31
@mattn
Copy link
Member Author

mattn commented Jan 31, 2026

This still wrong.

@mattn mattn force-pushed the fix-popup-wide-char-display branch from 3feed02 to 881447a Compare January 31, 2026 17:10
@mattn
Copy link
Member Author

mattn commented Jan 31, 2026

I have identified what is happening and what needs to be fixed.

This issue has two problems.

This pull request fixes only one of them. When the left edge of the popup dialog overlaps the right half of a multibyte character, set the redraw_this flag to TRUE.

And the other issue, where the right side of the pop-up dialog is not rendered correctly,
is fixed in:
#19299

mattn added 3 commits February 4, 2026 17:13
When a popup window with partially covers a wide character:
- If only the right half is visible, hide the entire character
- Clear garbage that would show through transparent popups

This ensures Vim's rule 'do not show wide chars with only half visible'
is properly enforced even with popup windows.
@mattn mattn force-pushed the fix-popup-wide-char-display branch from 881447a to d398f4b Compare February 4, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants