To: vim_dev@googlegroups.com Subject: Patch 8.2.4655 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4655 Problem: Command line completion popup menu positioned wrong when using a terminal window. Solution: Position the popup menu differently when editing the command line. (Yegappan Lakshmanan, closes #10050, closes #10035) Files: src/popupmenu.c, src/testdir/test_cmdline.vim, src/testdir/test_terminal.vim, src/testdir/dumps/Test_wildmenu_pum_term_01.dump *** ../vim-8.2.4654/src/popupmenu.c 2022-02-10 19:51:42.545569904 +0000 --- src/popupmenu.c 2022-03-31 12:30:46.245831298 +0100 *************** *** 100,105 **** --- 100,108 ---- #if defined(FEAT_QUICKFIX) win_T *pvwin; #endif + #ifdef FEAT_RIGHTLEFT + int right_left = State == CMDLINE ? FALSE : curwin->w_p_rl; + #endif do { *************** *** 156,166 **** { // pum above "pum_win_row" ! // Leave two lines of context if possible ! if (curwin->w_wrow - curwin->w_cline_row >= 2) ! context_lines = 2; else ! context_lines = curwin->w_wrow - curwin->w_cline_row; if (pum_win_row >= size + context_lines) { --- 159,175 ---- { // pum above "pum_win_row" ! if (State == CMDLINE) ! // for cmdline pum, no need for context lines ! context_lines = 0; else ! { ! // Leave two lines of context if possible ! if (curwin->w_wrow - curwin->w_cline_row >= 2) ! context_lines = 2; ! else ! context_lines = curwin->w_wrow - curwin->w_cline_row; ! } if (pum_win_row >= size + context_lines) { *************** *** 182,195 **** { // pum below "pum_win_row" ! // Leave two lines of context if possible ! validate_cheight(); ! if (curwin->w_cline_row ! + curwin->w_cline_height - curwin->w_wrow >= 3) ! context_lines = 3; else ! context_lines = curwin->w_cline_row ! + curwin->w_cline_height - curwin->w_wrow; pum_row = pum_win_row + context_lines; if (size > below_row - pum_row) --- 191,210 ---- { // pum below "pum_win_row" ! if (State == CMDLINE) ! // for cmdline pum, no need for context lines ! context_lines = 0; else ! { ! // Leave two lines of context if possible ! validate_cheight(); ! if (curwin->w_cline_row ! + curwin->w_cline_height - curwin->w_wrow >= 3) ! context_lines = 3; ! else ! context_lines = curwin->w_cline_row ! + curwin->w_cline_height - curwin->w_wrow; ! } pum_row = pum_win_row + context_lines; if (size > below_row - pum_row) *************** *** 226,232 **** else #endif #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) cursor_col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1; else --- 241,247 ---- else #endif #ifdef FEAT_RIGHTLEFT ! if (right_left) cursor_col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1; else *************** *** 245,256 **** 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 )) { --- 260,269 ---- if (def_width < max_width) def_width = max_width; ! if (((cursor_col < Columns - p_pw || cursor_col < Columns - max_width) #ifdef FEAT_RIGHTLEFT ! && !right_left) ! || (right_left && (cursor_col > p_pw || cursor_col > max_width) #endif )) { *************** *** 259,265 **** // start with the maximum space available #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) pum_width = pum_col - pum_scrollbar + 1; else #endif --- 272,278 ---- // start with the maximum space available #ifdef FEAT_RIGHTLEFT ! if (right_left) pum_width = pum_col - pum_scrollbar + 1; else #endif *************** *** 276,297 **** } 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 --- 289,310 ---- } else if (((cursor_col > p_pw || cursor_col > max_width) #ifdef FEAT_RIGHTLEFT ! && !right_left) ! || (right_left && (cursor_col < Columns - p_pw || cursor_col < Columns - max_width) #endif )) { // align pum edge with "cursor_col" #ifdef FEAT_RIGHTLEFT ! if (right_left && 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 (!right_left) #endif { if (curwin->w_wincol > Columns - max_width - pum_scrollbar *************** *** 305,311 **** } #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) pum_width = pum_col - pum_scrollbar + 1; else #endif --- 318,324 ---- } #ifdef FEAT_RIGHTLEFT ! if (right_left) pum_width = pum_col - pum_scrollbar + 1; else #endif *************** *** 315,321 **** { pum_width = p_pw; #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) { if (pum_width > pum_col) pum_width = pum_col; --- 328,334 ---- { pum_width = p_pw; #ifdef FEAT_RIGHTLEFT ! if (right_left) { if (pum_width > pum_col) pum_width = pum_col; *************** *** 343,349 **** { // not enough room, will use what we have #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) pum_col = Columns - 1; else #endif --- 356,362 ---- { // not enough room, will use what we have #ifdef FEAT_RIGHTLEFT ! if (right_left) pum_col = Columns - 1; else #endif *************** *** 355,361 **** if (max_width > p_pw) max_width = p_pw; // truncate #ifdef FEAT_RIGHTLEFT ! if (curwin->w_p_rl) pum_col = max_width - 1; else #endif --- 368,374 ---- if (max_width > p_pw) max_width = p_pw; // truncate #ifdef FEAT_RIGHTLEFT ! if (right_left) pum_col = max_width - 1; else #endif *** ../vim-8.2.4654/src/testdir/test_cmdline.vim 2022-03-25 21:19:22.115496681 +0000 --- src/testdir/test_cmdline.vim 2022-03-31 12:19:19.854298490 +0100 *************** *** 2510,2515 **** --- 2510,2539 ---- cunmap endfunc + " Test for opening the cmdline completion popup menu from the terminal window. + " The popup menu should be positioned correctly over the status line of the + " bottom-most window. + func Test_wildmenu_pum_from_terminal() + CheckRunVimInTerminal + let python = PythonProg() + call CheckPython(python) + + %bw! + let cmds = ['set wildmenu wildoptions=pum'] + let pcmd = python .. ' -c "import sys; sys.stdout.write(sys.stdin.read())"' + call add(cmds, "call term_start('" .. pcmd .. "')") + call writefile(cmds, 'Xtest') + let buf = RunVimInTerminal('-S Xtest', #{rows: 10}) + call term_sendkeys(buf, "\r\r\r") + call term_wait(buf) + call term_sendkeys(buf, "\:sign \") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_wildmenu_pum_term_01', {}) + call term_wait(buf) + call StopVimInTerminal(buf) + call delete('Xtest') + endfunc + " Test for completion after a :substitute command followed by a pipe (|) " character func Test_cmdline_complete_substitute() *** ../vim-8.2.4654/src/testdir/test_terminal.vim 2022-02-23 14:25:08.143591156 +0000 --- src/testdir/test_terminal.vim 2022-03-31 12:19:19.854298490 +0100 *************** *** 935,941 **** tunmap 123 tunmap 456 call assert_equal('', maparg('123', 't')) ! close unlet g:job endfunc --- 935,941 ---- tunmap 123 tunmap 456 call assert_equal('', maparg('123', 't')) ! exe buf . 'bwipe' unlet g:job endfunc *** ../vim-8.2.4654/src/testdir/dumps/Test_wildmenu_pum_term_01.dump 2022-03-31 12:33:32.989717171 +0100 --- src/testdir/dumps/Test_wildmenu_pum_term_01.dump 2022-03-31 12:19:19.854298490 +0100 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + @75 + @75 + @5| +0#0000001#e0e0e08|d|e|f|i|n|e| @8| +0#0000000#ffffff0@53 + |<+2#ffffff16#00e0003|o|r|t| | +0#0000001#ffd7ff255|j|u|m|p| @10|w+2#ffffff16#00e0003|r|i|t|e|(|s|y|s|.|s|t|d|i|n|.|r|e|a|d|(|)@1|"| |[|r|u|n@1|i|n|g|]| @1|0|,|0|-|1| @9|A|l@1 + | +0#0000000#ffffff0@4| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#0000000#ffffff0@53 + |~+0#4040ff13&| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |[+1#0000000&|N|o| |N| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +1#0000000#ffffff0@35|0|,|0|-|1| @9|A|l@1 + |:+0&&|s|i|g|n| |d|e|f|i|n|e> @62 *** ../vim-8.2.4654/src/version.c 2022-03-31 11:51:18.051324192 +0100 --- src/version.c 2022-03-31 12:21:52.386195136 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4655, /**/ -- [Autumn changed into Winter ... Winter changed into Spring ... Spring changed back into Autumn and Autumn gave Winter and Spring a miss and went straight on into Summer ... Until one day ...] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///