Mercurial > vim
comparison src/popupwin.c @ 18492:41a5f241e9d5 v8.1.2240
patch 8.1.2240: popup window width changes when scrolling
Commit: https://github.com/vim/vim/commit/f2885d3fb7045d14ae58824e9cb8dea65e4052c4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 2 20:21:25 2019 +0100
patch 8.1.2240: popup window width changes when scrolling
Problem: Popup window width changes when scrolling.
Solution: Also adjust maxwidth when applying minwidth and there is a
scrollbar. Fix off-by-one error. (closes #5162)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 02 Nov 2019 20:30:03 +0100 |
parents | 144fa40ee706 |
children | e855058e0c23 |
comparison
equal
deleted
inserted
replaced
18491:2ccbede92fd5 | 18492:41a5f241e9d5 |
---|---|
1199 if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth) | 1199 if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth) |
1200 { | 1200 { |
1201 allow_adjust_left = FALSE; | 1201 allow_adjust_left = FALSE; |
1202 maxwidth = wp->w_maxwidth; | 1202 maxwidth = wp->w_maxwidth; |
1203 } | 1203 } |
1204 minwidth = wp->w_minwidth; | |
1204 | 1205 |
1205 // start at the desired first line | 1206 // start at the desired first line |
1206 if (wp->w_firstline > 0) | 1207 if (wp->w_firstline > 0) |
1207 wp->w_topline = wp->w_firstline; | 1208 wp->w_topline = wp->w_firstline; |
1208 if (wp->w_topline < 1) | 1209 if (wp->w_topline < 1) |
1268 { | 1269 { |
1269 wp->w_width = len; | 1270 wp->w_width = len; |
1270 if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth) | 1271 if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth) |
1271 wp->w_width = wp->w_maxwidth; | 1272 wp->w_width = wp->w_maxwidth; |
1272 } | 1273 } |
1274 | |
1275 if (wp->w_firstline < 0) | |
1276 --lnum; | |
1277 else | |
1278 ++lnum; | |
1279 | |
1273 // do not use the width of lines we're not going to show | 1280 // do not use the width of lines we're not going to show |
1274 if (wp->w_maxheight > 0 | 1281 if (wp->w_maxheight > 0 |
1275 && (wp->w_firstline >= 0 | 1282 && (wp->w_firstline >= 0 |
1276 ? lnum - wp->w_topline | 1283 ? lnum - wp->w_topline |
1277 : wp->w_buffer->b_ml.ml_line_count - lnum) | 1284 : wp->w_buffer->b_ml.ml_line_count - lnum) |
1278 + 1 + wrapped > wp->w_maxheight) | 1285 + wrapped >= wp->w_maxheight) |
1279 break; | 1286 break; |
1280 | |
1281 if (wp->w_firstline < 0) | |
1282 --lnum; | |
1283 else | |
1284 ++lnum; | |
1285 } | 1287 } |
1286 | 1288 |
1287 if (wp->w_firstline < 0) | 1289 if (wp->w_firstline < 0) |
1288 wp->w_topline = lnum > 0 ? lnum + 1 : lnum; | 1290 wp->w_topline = lnum > 0 ? lnum + 1 : lnum; |
1289 | 1291 |
1291 && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count); | 1293 && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count); |
1292 if (wp->w_has_scrollbar) | 1294 if (wp->w_has_scrollbar) |
1293 { | 1295 { |
1294 ++right_extra; | 1296 ++right_extra; |
1295 ++extra_width; | 1297 ++extra_width; |
1296 if (used_maxwidth) | 1298 // make space for the scrollbar if needed, when lines wrap and when |
1297 maxwidth -= 2; // try to show the scrollbar | 1299 // applying minwidth |
1298 } | 1300 if (maxwidth + right_extra >= maxspace |
1299 | 1301 && (used_maxwidth || (minwidth > 0 && wp->w_width < minwidth))) |
1300 minwidth = wp->w_minwidth; | 1302 maxwidth -= wp->w_popup_padding[1] + 1; |
1303 } | |
1304 | |
1301 if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL) | 1305 if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL) |
1302 { | 1306 { |
1303 int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width; | 1307 int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width; |
1304 | 1308 |
1305 if (minwidth < title_len) | 1309 if (minwidth < title_len) |