Mercurial > vim
diff src/popupwin.c @ 17897:fa032e079825 v8.1.1945
patch 8.1.1945: popup window "firstline" cannot be reset
Commit: https://github.com/vim/vim/commit/9e67b6a6a126f401417590dedf1bd38f71bfbae4
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 30 17:34:08 2019 +0200
patch 8.1.1945: popup window "firstline" cannot be reset
Problem: Popup window "firstline" cannot be reset.
Solution: Allow for setting "firstline" to zero. Fix that the text jumps to
the top when using win_execute(). (closes #4876)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 30 Aug 2019 17:45:04 +0200 |
parents | 5d5b460926ca |
children | fb773f73a4be |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -610,8 +610,8 @@ apply_general_options(win_T *wp, dict_T di = dict_find(dict, (char_u *)"firstline", -1); if (di != NULL) wp->w_firstline = dict_get_number(dict, (char_u *)"firstline"); - if (wp->w_firstline < 1) - wp->w_firstline = 1; + if (wp->w_firstline < 0) + wp->w_firstline = 0; di = dict_find(dict, (char_u *)"scrollbar", -1); if (di != NULL) @@ -3192,8 +3192,17 @@ update_popups(void (*win_update)(win_T * // Draw the popup text, unless it's off screen. if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns) + { win_update(wp); + // move the cursor into the visible lines, otherwise executing + // commands with win_execute() may cause the text to jump. + if (wp->w_cursor.lnum < wp->w_topline) + wp->w_cursor.lnum = wp->w_topline; + else if (wp->w_cursor.lnum >= wp->w_botline) + wp->w_cursor.lnum = wp->w_botline - 1; + } + wp->w_winrow -= top_off; wp->w_wincol -= left_extra;