comparison 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
comparison
equal deleted inserted replaced
17896:6807cb2ca23c 17897:fa032e079825
608 // TODO: flip 608 // TODO: flip
609 609
610 di = dict_find(dict, (char_u *)"firstline", -1); 610 di = dict_find(dict, (char_u *)"firstline", -1);
611 if (di != NULL) 611 if (di != NULL)
612 wp->w_firstline = dict_get_number(dict, (char_u *)"firstline"); 612 wp->w_firstline = dict_get_number(dict, (char_u *)"firstline");
613 if (wp->w_firstline < 1) 613 if (wp->w_firstline < 0)
614 wp->w_firstline = 1; 614 wp->w_firstline = 0;
615 615
616 di = dict_find(dict, (char_u *)"scrollbar", -1); 616 di = dict_find(dict, (char_u *)"scrollbar", -1);
617 if (di != NULL) 617 if (di != NULL)
618 wp->w_want_scrollbar = dict_get_number(dict, (char_u *)"scrollbar"); 618 wp->w_want_scrollbar = dict_get_number(dict, (char_u *)"scrollbar");
619 619
3190 wp->w_winrow += top_off; 3190 wp->w_winrow += top_off;
3191 wp->w_wincol += left_extra; 3191 wp->w_wincol += left_extra;
3192 3192
3193 // Draw the popup text, unless it's off screen. 3193 // Draw the popup text, unless it's off screen.
3194 if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns) 3194 if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns)
3195 {
3195 win_update(wp); 3196 win_update(wp);
3197
3198 // move the cursor into the visible lines, otherwise executing
3199 // commands with win_execute() may cause the text to jump.
3200 if (wp->w_cursor.lnum < wp->w_topline)
3201 wp->w_cursor.lnum = wp->w_topline;
3202 else if (wp->w_cursor.lnum >= wp->w_botline)
3203 wp->w_cursor.lnum = wp->w_botline - 1;
3204 }
3196 3205
3197 wp->w_winrow -= top_off; 3206 wp->w_winrow -= top_off;
3198 wp->w_wincol -= left_extra; 3207 wp->w_wincol -= left_extra;
3199 3208
3200 total_width = popup_width(wp); 3209 total_width = popup_width(wp);