Mercurial > vim
comparison src/popupmnu.c @ 13242:5b0faf628a55 v8.0.1495
patch 8.0.1495: having 'pumwidth' default to zero has no merit
commit https://github.com/vim/vim/commit/42443c7d7fecc3a2a72154bb6139b028438617c2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 10 18:28:52 2018 +0100
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Problem: Having 'pumwidth' default to zero has no merit.
Solution: Make the default 15, as the actual default value.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Feb 2018 18:30:08 +0100 |
parents | 6e972d830e13 |
children | ac42c4b11dbc |
comparison
equal
deleted
inserted
replaced
13241:fc8a7fb28903 | 13242:5b0faf628a55 |
---|---|
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 /* | 69 /* |
70 * Return the minimum width of the popup menu. | |
71 */ | |
72 static int | |
73 pum_get_width(void) | |
74 { | |
75 return p_pw == 0 ? PUM_DEF_WIDTH : p_pw; | |
76 } | |
77 | |
78 /* | |
79 * Show the popup menu with items "array[size]". | 70 * Show the popup menu with items "array[size]". |
80 * "array" must remain valid until pum_undisplay() is called! | 71 * "array" must remain valid until pum_undisplay() is called! |
81 * When possible the leftmost character is aligned with screen column "col". | 72 * When possible the leftmost character is aligned with screen column "col". |
82 * The menu appears above the screen line "row" or at "row" + "height" - 1. | 73 * The menu appears above the screen line "row" or at "row" + "height" - 1. |
83 */ | 74 */ |
100 win_T *pvwin; | 91 win_T *pvwin; |
101 #endif | 92 #endif |
102 | 93 |
103 do | 94 do |
104 { | 95 { |
105 def_width = pum_get_width(); | 96 def_width = p_pw; |
106 above_row = 0; | 97 above_row = 0; |
107 below_row = cmdline_row; | 98 below_row = cmdline_row; |
108 | 99 |
109 /* Pretend the pum is already there to avoid that must_redraw is set | 100 /* Pretend the pum is already there to avoid that must_redraw is set |
110 * when 'cuc' is on. */ | 101 * when 'cuc' is on. */ |
223 pum_scrollbar = 0; | 214 pum_scrollbar = 0; |
224 | 215 |
225 if (def_width < max_width) | 216 if (def_width < max_width) |
226 def_width = max_width; | 217 def_width = max_width; |
227 | 218 |
228 if (((col < Columns - pum_get_width() || col < Columns - max_width) | 219 if (((col < Columns - p_pw || col < Columns - max_width) |
229 #ifdef FEAT_RIGHTLEFT | 220 #ifdef FEAT_RIGHTLEFT |
230 && !curwin->w_p_rl) | 221 && !curwin->w_p_rl) |
231 || (curwin->w_p_rl && (col > pum_get_width() || col > max_width) | 222 || (curwin->w_p_rl && (col > p_pw || col > max_width) |
232 #endif | 223 #endif |
233 )) | 224 )) |
234 { | 225 { |
235 /* align pum column with "col" */ | 226 /* align pum column with "col" */ |
236 pum_col = col; | 227 pum_col = col; |
242 else | 233 else |
243 #endif | 234 #endif |
244 pum_width = Columns - pum_col - pum_scrollbar; | 235 pum_width = Columns - pum_col - pum_scrollbar; |
245 | 236 |
246 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 | 237 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 |
247 && pum_width > pum_get_width()) | 238 && pum_width > p_pw) |
248 { | 239 { |
249 /* the width is too much, make it narrower */ | 240 /* the width is too much, make it narrower */ |
250 pum_width = max_width + pum_kind_width + pum_extra_width + 1; | 241 pum_width = max_width + pum_kind_width + pum_extra_width + 1; |
251 if (pum_width < pum_get_width()) | 242 if (pum_width < p_pw) |
252 pum_width = pum_get_width(); | 243 pum_width = p_pw; |
253 } | 244 } |
254 else if (((col > pum_get_width() || col > max_width) | 245 else if (((col > p_pw || col > max_width) |
255 #ifdef FEAT_RIGHTLEFT | 246 #ifdef FEAT_RIGHTLEFT |
256 && !curwin->w_p_rl) | 247 && !curwin->w_p_rl) |
257 || (curwin->w_p_rl && (col < Columns - pum_get_width() | 248 || (curwin->w_p_rl && (col < Columns - p_pw |
258 || col < Columns - max_width) | 249 || col < Columns - max_width) |
259 #endif | 250 #endif |
260 )) | 251 )) |
261 { | 252 { |
262 /* align right pum edge with "col" */ | 253 /* align right pum edge with "col" */ |
280 pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 1; | 271 pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 1; |
281 else | 272 else |
282 #endif | 273 #endif |
283 pum_width = pum_col - pum_scrollbar; | 274 pum_width = pum_col - pum_scrollbar; |
284 | 275 |
285 if (pum_width < pum_get_width()) | 276 if (pum_width < p_pw) |
286 { | 277 { |
287 pum_width = pum_get_width(); | 278 pum_width = p_pw; |
288 #ifdef FEAT_RIGHTLEFT | 279 #ifdef FEAT_RIGHTLEFT |
289 if (curwin->w_p_rl) | 280 if (curwin->w_p_rl) |
290 { | 281 { |
291 if (pum_width > pum_col) | 282 if (pum_width > pum_col) |
292 pum_width = pum_col; | 283 pum_width = pum_col; |
298 pum_width = Columns - pum_col - 1; | 289 pum_width = Columns - pum_col - 1; |
299 } | 290 } |
300 } | 291 } |
301 else if (pum_width > max_width + pum_kind_width | 292 else if (pum_width > max_width + pum_kind_width |
302 + pum_extra_width + 1 | 293 + pum_extra_width + 1 |
303 && pum_width > pum_get_width()) | 294 && pum_width > p_pw) |
304 { | 295 { |
305 pum_width = max_width + pum_kind_width | 296 pum_width = max_width + pum_kind_width |
306 + pum_extra_width + 1; | 297 + pum_extra_width + 1; |
307 if (pum_width < pum_get_width()) | 298 if (pum_width < p_pw) |
308 pum_width = pum_get_width(); | 299 pum_width = p_pw; |
309 } | 300 } |
310 } | 301 } |
311 | 302 |
312 } | 303 } |
313 else if (Columns < def_width) | 304 else if (Columns < def_width) |
321 pum_col = 0; | 312 pum_col = 0; |
322 pum_width = Columns - 1; | 313 pum_width = Columns - 1; |
323 } | 314 } |
324 else | 315 else |
325 { | 316 { |
326 if (max_width > pum_get_width()) | 317 if (max_width > p_pw) |
327 max_width = pum_get_width(); /* truncate */ | 318 max_width = p_pw; /* truncate */ |
328 #ifdef FEAT_RIGHTLEFT | 319 #ifdef FEAT_RIGHTLEFT |
329 if (curwin->w_p_rl) | 320 if (curwin->w_p_rl) |
330 pum_col = max_width - 1; | 321 pum_col = max_width - 1; |
331 else | 322 else |
332 #endif | 323 #endif |