comparison src/popupwin.c @ 18339:a776385eac9f v8.1.2164

patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu Commit: https://github.com/vim/vim/commit/7b3d93966709998011e2eb3b84414ff454161b37 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 16 22:17:07 2019 +0200 patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu Problem: Stuck when using "j" in a popupwin with popup_filter_menu if a line wraps. Solution: Check the cursor line is visible. (closes #4577)
author Bram Moolenaar <Bram@vim.org>
date Wed, 16 Oct 2019 22:30:04 +0200
parents 9e696b8fee7d
children ba5d8c5d77d7
comparison
equal deleted inserted replaced
18338:93ce94d4d30c 18339:a776385eac9f
533 } 533 }
534 } 534 }
535 } 535 }
536 536
537 /* 537 /*
538 * Scroll to show the line with the cursor. This assumes lines don't wrap. 538 * Scroll to show the line with the cursor.
539 */ 539 */
540 static void 540 static void
541 popup_show_curline(win_T *wp) 541 popup_show_curline(win_T *wp)
542 { 542 {
543 if (wp->w_cursor.lnum < wp->w_topline) 543 if (wp->w_cursor.lnum < wp->w_topline)
548 wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1; 548 wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1;
549 if (wp->w_topline < 1) 549 if (wp->w_topline < 1)
550 wp->w_topline = 1; 550 wp->w_topline = 1;
551 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count) 551 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
552 wp->w_topline = wp->w_buffer->b_ml.ml_line_count; 552 wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
553 while (wp->w_topline < wp->w_cursor.lnum
554 && wp->w_topline < wp->w_buffer->b_ml.ml_line_count
555 && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum)
556 > wp->w_height)
557 ++wp->w_topline;
553 } 558 }
554 559
555 // Don't use "firstline" now. 560 // Don't use "firstline" now.
556 wp->w_firstline = 0; 561 wp->w_firstline = 0;
557 } 562 }
1039 popup_adjust_position(win_T *wp) 1044 popup_adjust_position(win_T *wp)
1040 { 1045 {
1041 linenr_T lnum; 1046 linenr_T lnum;
1042 int wrapped = 0; 1047 int wrapped = 0;
1043 int maxwidth; 1048 int maxwidth;
1049 int used_maxwidth = FALSE;
1044 int maxspace; 1050 int maxspace;
1045 int center_vert = FALSE; 1051 int center_vert = FALSE;
1046 int center_hor = FALSE; 1052 int center_hor = FALSE;
1047 int allow_adjust_left = !wp->w_popup_fixed; 1053 int allow_adjust_left = !wp->w_popup_fixed;
1048 int top_extra = popup_top_extra(wp); 1054 int top_extra = popup_top_extra(wp);
1206 while (len > maxwidth) 1212 while (len > maxwidth)
1207 { 1213 {
1208 ++wrapped; 1214 ++wrapped;
1209 len -= maxwidth; 1215 len -= maxwidth;
1210 wp->w_width = maxwidth; 1216 wp->w_width = maxwidth;
1217 used_maxwidth = TRUE;
1211 } 1218 }
1212 } 1219 }
1213 else if (len > maxwidth 1220 else if (len > maxwidth
1214 && allow_adjust_left 1221 && allow_adjust_left
1215 && (wp->w_popup_pos == POPPOS_TOPLEFT 1222 && (wp->w_popup_pos == POPPOS_TOPLEFT
1257 && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count); 1264 && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count);
1258 if (wp->w_has_scrollbar) 1265 if (wp->w_has_scrollbar)
1259 { 1266 {
1260 ++right_extra; 1267 ++right_extra;
1261 ++extra_width; 1268 ++extra_width;
1269 if (used_maxwidth)
1270 maxwidth -= 2; // try to show the scrollbar
1262 } 1271 }
1263 1272
1264 minwidth = wp->w_minwidth; 1273 minwidth = wp->w_minwidth;
1265 if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL) 1274 if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
1266 { 1275 {