mirror of
https://github.com/vim/vim.git
synced 2025-10-28 09:27:14 -04:00
patch 9.1.1650: popup: window may not properly resize
Problem: After scrolling a popup and then using popup_settext() with
fewer lines, the popup fails to resize properly because
firstline points beyond the new buffer content (lifepillar)
Solution: In popup_adjust_position(), validate that firstline doesn't
exceed buffer line count and reset to 0 (auto-position) if it
does (glepnir)
fixes: #14745
closes: #18031
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
c7c10f8c11
commit
31170af24a
@@ -1403,7 +1403,15 @@ popup_adjust_position(win_T *wp)
|
||||
|
||||
// start at the desired first line
|
||||
if (wp->w_firstline > 0)
|
||||
wp->w_topline = wp->w_firstline;
|
||||
{
|
||||
// If firstline is beyond the buffer content, reset it to auto-position.
|
||||
// This can happen when the popup was scrolled and then the buffer
|
||||
// content was changed to have fewer lines.
|
||||
if (wp->w_firstline > wp->w_buffer->b_ml.ml_line_count)
|
||||
wp->w_firstline = 0;
|
||||
else
|
||||
wp->w_topline = wp->w_firstline;
|
||||
}
|
||||
if (wp->w_topline < 1)
|
||||
wp->w_topline = 1;
|
||||
else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
|
||||
|
||||
Reference in New Issue
Block a user