Skip to content

Fix Popup Redraw Issues and Borderhighlight Clearing#19297

Open
mattn wants to merge 2 commits intovim:masterfrom
mattn:popup-redraw-fix
Open

Fix Popup Redraw Issues and Borderhighlight Clearing#19297
mattn wants to merge 2 commits intovim:masterfrom
mattn:popup-redraw-fix

Conversation

@mattn
Copy link
Member

@mattn mattn commented Jan 31, 2026

This PR fixes several issues related to popup window rendering and option handling in Vim.

Problem 1: Ghost Images When Moving Popups

When using popup_move() to move a popup window (e.g., with hjkl keys in the vim-popup-manager plugin), ghost images of the popup remained on the screen. The old position was not being redrawn.

Solution

Modified f_popup_move() in popupwin.c to save the old position before moving and force a full redraw when the position changes.

Problem 2: Visual Options Not Redrawn

When calling popup_setoptions() with visual options like borderhighlight, scrollbarhighlight, thumbhighlight, zindex, or cursorline flags, the changes were not immediately visible because no redraw was triggered.

Solution

Enhanced f_popup_setoptions() to check for changes in visual-affecting options and trigger a redraw when any of them change:

  • firstline (already existed)
  • zindex
  • Popup flags (cursorline, drag, resize, etc.)
  • scrollbarhighlight
  • thumbhighlight
  • borderhighlight array

Problem 3: Cannot Clear borderhighlight

Setting borderhighlight: [] did not clear the border highlights. The loop that processed the list only updated highlights when the list had items, so an empty list would not clear existing highlights.

Solution

Modified the borderhighlight processing in apply_general_options() to explicitly clear all border highlights when an empty list is provided.

Changes

Files Modified

  • src/popupwin.c: Core fixes for popup rendering
  • src/testdir/test_popupwin.vim: Added test for borderhighlight clearing

Test Added

" Check that borderhighlight can be cleared with empty list
call popup_setoptions(winid, #{borderhighlight: []})
let options_cleared = popup_getoptions(winid)
call assert_equal([], options_cleared.borderhighlight)

Testing

  1. Build Vim with these changes
  2. Test with vim-popup-manager plugin - hjkl movement should not leave ghost images
  3. Test borderhighlight clearing:
    let winid = popup_create('test', #{border: [], borderhighlight: ['WarningMsg']})
    call popup_setoptions(winid, #{borderhighlight: []})
    " Border highlight should now be cleared

mattn added 2 commits January 31, 2026 21:39
- Fix popup_move() to redraw old position to clear ghost images
- Fix popup_setoptions() to redraw when visual options change
- Fix borderhighlight to be cleared with empty list []
- Add test for borderhighlight clearing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants