To: vim_dev@googlegroups.com Subject: Patch 8.0.1540 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1540 Problem: Popup menu positioning fails with longer string. Solution: Only align with right side of window when width is less than 'pumwidth' (closes #2661) Files: src/popupmnu.c, src/testdir/screendump.vim, src/testdir/test_popup.vim, src/testdir/dumps/Test_popup_position_04.dump *** ../vim-8.0.1539/src/popupmnu.c 2018-02-24 18:59:18.890876335 +0100 --- src/popupmnu.c 2018-02-24 21:18:25.161288727 +0100 *************** *** 69,75 **** /* * Show the popup menu with items "array[size]". * "array" must remain valid until pum_undisplay() is called! ! * When possible the leftmost character is aligned with screen column "col". * The menu appears above the screen line "row" or at "row" + "height" - 1. */ void --- 69,75 ---- /* * Show the popup menu with items "array[size]". * "array" must remain valid until pum_undisplay() is called! ! * When possible the leftmost character is aligned with cursor column. * The menu appears above the screen line "row" or at "row" + "height" - 1. */ void *************** *** 83,89 **** int max_width; int row; int context_lines; ! int col; int above_row; int below_row; int redo_count = 0; --- 83,89 ---- int max_width; int row; int context_lines; ! int cursor_col; int above_row; int below_row; int redo_count = 0; *************** *** 199,208 **** /* Calculate column */ #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) ! col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1; else #endif ! col = curwin->w_wincol + curwin->w_wcol; /* if there are more items than room we need a scrollbar */ if (pum_height < size) --- 199,209 ---- /* Calculate column */ #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) ! cursor_col = curwin->w_wincol + curwin->w_width ! - curwin->w_wcol - 1; else #endif ! cursor_col = curwin->w_wincol + curwin->w_wcol; /* if there are more items than room we need a scrollbar */ if (pum_height < size) *************** *** 216,230 **** if (def_width < max_width) def_width = max_width; ! if (((col < Columns - p_pw || col < Columns - max_width) #ifdef FEAT_RIGHTLEFT && !curwin->w_p_rl) ! || (curwin->w_p_rl && (col > p_pw || col > max_width) #endif )) { ! /* align pum column with "col" */ ! pum_col = col; /* start with the maximum space available */ #ifdef FEAT_RIGHTLEFT --- 217,233 ---- if (def_width < max_width) def_width = max_width; ! if (((cursor_col < Columns - p_pw ! || cursor_col < Columns - max_width) #ifdef FEAT_RIGHTLEFT && !curwin->w_p_rl) ! || (curwin->w_p_rl ! && (cursor_col > p_pw || cursor_col > max_width) #endif )) { ! /* align pum with "cursor_col" */ ! pum_col = cursor_col; /* start with the maximum space available */ #ifdef FEAT_RIGHTLEFT *************** *** 237,269 **** if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 && pum_width > p_pw) { ! /* the width is too much, make it narrower */ pum_width = max_width + pum_kind_width + pum_extra_width + 1; if (pum_width < p_pw) pum_width = p_pw; } ! else if (((col > p_pw || col > max_width) #ifdef FEAT_RIGHTLEFT && !curwin->w_p_rl) ! || (curwin->w_p_rl && (col < Columns - p_pw ! || col < Columns - max_width) #endif )) { ! /* align right pum edge with "col" */ #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl && W_ENDCOL(curwin) < max_width + pum_scrollbar + 1) { ! pum_col = col + max_width + pum_scrollbar + 1; if (pum_col >= Columns) pum_col = Columns - 1; } else if (!curwin->w_p_rl) #endif { ! if (curwin->w_wincol > Columns - max_width - pum_scrollbar) { pum_col = Columns - max_width - pum_scrollbar; if (pum_col < 0) pum_col = 0; --- 240,275 ---- if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 && pum_width > p_pw) { ! /* the width is more than needed for the items, make it ! * narrower */ pum_width = max_width + pum_kind_width + pum_extra_width + 1; if (pum_width < p_pw) pum_width = p_pw; } ! else if (((cursor_col > p_pw || cursor_col > max_width) #ifdef FEAT_RIGHTLEFT && !curwin->w_p_rl) ! || (curwin->w_p_rl && (cursor_col < Columns - p_pw ! || cursor_col < Columns - max_width) #endif )) { ! /* align pum edge with "cursor_col" */ #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl && W_ENDCOL(curwin) < max_width + pum_scrollbar + 1) { ! pum_col = cursor_col + max_width + pum_scrollbar + 1; if (pum_col >= Columns) pum_col = Columns - 1; } else if (!curwin->w_p_rl) #endif { ! if (curwin->w_wincol > Columns - max_width - pum_scrollbar ! && max_width <= p_pw) { + /* use full width to end of the screen */ pum_col = Columns - max_width - pum_scrollbar; if (pum_col < 0) pum_col = 0; *** ../vim-8.0.1539/src/testdir/screendump.vim 2018-02-24 19:53:09.142750492 +0100 --- src/testdir/screendump.vim 2018-02-24 20:15:12.750029855 +0100 *************** *** 48,54 **** " Stop a Vim running in terminal buffer "buf". func StopVimInTerminal(buf) call assert_equal("running", term_getstatus(a:buf)) ! call term_sendkeys(a:buf, ":qa!\") call WaitFor('term_getstatus(' . a:buf . ') == "finished"') only! endfunc --- 48,54 ---- " Stop a Vim running in terminal buffer "buf". func StopVimInTerminal(buf) call assert_equal("running", term_getstatus(a:buf)) ! call term_sendkeys(a:buf, "\\:qa!\") call WaitFor('term_getstatus(' . a:buf . ') == "finished"') only! endfunc *** ../vim-8.0.1539/src/testdir/test_popup.vim 2018-02-24 19:53:09.142750492 +0100 --- src/testdir/test_popup.vim 2018-02-24 20:44:00.243139432 +0100 *************** *** 772,777 **** --- 772,786 ---- call term_sendkeys(buf, "GA\") call VerifyScreenDump(buf, 'Test_popup_position_03', {'rows': 8}) + " completed text wider than the window and 'pumwidth' smaller than available + " space + call term_sendkeys(buf, "\u") + call term_sendkeys(buf, ":set pumwidth=20\") + call term_sendkeys(buf, "ggI123456789_\") + call term_sendkeys(buf, "jI123456789_\") + call term_sendkeys(buf, "GA\") + call VerifyScreenDump(buf, 'Test_popup_position_04', {'rows': 10}) + call term_sendkeys(buf, "\u") call StopVimInTerminal(buf) call delete('Xtest') *** ../vim-8.0.1539/src/testdir/dumps/Test_popup_position_04.dump 2018-02-24 21:24:58.814670715 +0100 --- src/testdir/dumps/Test_popup_position_04.dump 2018-02-24 21:21:18.352131259 +0100 *************** *** 0 **** --- 1,10 ---- + |1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7 + |8|9|_|a| @32||+1&&|8+0&&|9|_|a| @32 + |1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7 + |8|9|_|b| @32||+1&&|8+0&&|9|_|b| @32 + @12|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5||+1&&| +0&&@11|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5 + |6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @20||+1&&|6+0&&|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @20 + |~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @9| +0#0000001#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5 + |~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @9| +0#0000001#ffd7ff255|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5 + |~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 *** ../vim-8.0.1539/src/version.c 2018-02-24 19:53:09.150750442 +0100 --- src/version.c 2018-02-24 20:36:23.802005559 +0100 *************** *** 780,781 **** --- 780,783 ---- { /* Add new patch number below this line */ + /**/ + 1540, /**/ -- Citizens are not allowed to attend a movie house or theater nor ride in a public streetcar within at least four hours after eating garlic. [real standing law in Indiana, United States of America] /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///