diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-18 18:32:19 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-18 18:32:19 +0100 |
commit | 3aca0916f0dba6114ae0f7d5458763a934fe7a02 (patch) | |
tree | 0cd7630487f8bf45e38e7a28495e1c86f16fe4b1 | |
parent | 1693712f0263afb929ebca1159ceb17c1563ee3b (diff) |
patch 8.2.4785: Visual mode not stopped if win_gotoid() goes to other bufferv8.2.4785
Problem: Visual mode not stopped early enough if win_gotoid() goes to
another buffer. (Sergey Vlasov)
Solution: Stop Visual mode before jumping to another buffer. (closes #10217)
-rw-r--r-- | src/evalwindow.c | 3 | ||||
-rw-r--r-- | src/testdir/dumps/Test_win_gotoid_1.dump | 15 | ||||
-rw-r--r-- | src/testdir/dumps/Test_win_gotoid_2.dump | 15 | ||||
-rw-r--r-- | src/testdir/dumps/Test_win_gotoid_3.dump | 15 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 41 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 91 insertions, 0 deletions
diff --git a/src/evalwindow.c b/src/evalwindow.c index f6bc79f9e8..53fd1e3569 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -817,6 +817,9 @@ f_win_gotoid(typval_T *argvars, typval_T *rettv) FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_id == id) { + // When jumping to another buffer stop Visual mode. + if (VIsual_active && wp->w_buffer != curbuf) + end_visual_mode(); goto_tabpage_win(tp, wp); rettv->vval.v_number = 1; return; diff --git a/src/testdir/dumps/Test_win_gotoid_1.dump b/src/testdir/dumps/Test_win_gotoid_1.dump new file mode 100644 index 0000000000..0faf57980b --- /dev/null +++ b/src/testdir/dumps/Test_win_gotoid_1.dump @@ -0,0 +1,15 @@ +|0+0&#ffffff0| @73 +|1| @73 +|2| @73 +|3| @73 +|4| @73 +|[+1&&|N|o| |N|a|m|e|]| @47|1|,|1| @11|T|o|p +>2+0&&|1| @72 +|2@1| @72 +|2|3| @72 +|2|4| @72 +|2|5| @72 +|2|6| @72 +|[+3&&|N|o| |N|a|m|e|]| @47|1|,|1| @11|T|o|p +|r+0&&|e|g| |=| |"|f|o@1|"| @63 +@75 diff --git a/src/testdir/dumps/Test_win_gotoid_2.dump b/src/testdir/dumps/Test_win_gotoid_2.dump new file mode 100644 index 0000000000..7a778f5e3d --- /dev/null +++ b/src/testdir/dumps/Test_win_gotoid_2.dump @@ -0,0 +1,15 @@ +|0+0&#ffffff0| @73 +|1| @73 +|2| @73 +|3| @73 +|4| @73 +|[+1&&|N|o| |N|a|m|e|]| @47|1|,|1| @11|T|o|p +|2+0&&|1| @72 +|2@1| @72 +|2+0&#e0e0e08>3+0&#ffffff0| @72 +|2|4| @72 +|2|5| @72 +|2|6| @72 +|[+3&&|N|o| |N|a|m|e|]| @47|3|,|2| @11|T|o|p +|r+0&&|e|g| |=| |"|2|3|"| @64 +|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2| @9 diff --git a/src/testdir/dumps/Test_win_gotoid_3.dump b/src/testdir/dumps/Test_win_gotoid_3.dump new file mode 100644 index 0000000000..2de7346f65 --- /dev/null +++ b/src/testdir/dumps/Test_win_gotoid_3.dump @@ -0,0 +1,15 @@ +|0+0&#ffffff0| @73 +|1| @73 +>2| @73 +|3| @73 +|4| @73 +|[+3&&|N|o| |N|a|m|e|]| @47|3|,|1| @11|T|o|p +|2+0&&|1| @72 +|2@1| @72 +|2|3| @72 +|2|4| @72 +|2|5| @72 +|2|6| @72 +|[+1&&|N|o| |N|a|m|e|]| @47|3|,|1| @11|T|o|p +|r+0&&|e|g| |=| |"|2|3|"| @64 +@75 diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 9e60666d3d..7dde24c68c 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -1,6 +1,7 @@ " Test using builtin functions in the Vim9 script language. source check.vim +source screendump.vim import './vim9.vim' as v9 " Test for passing too many or too few arguments to builtin functions @@ -4493,6 +4494,46 @@ def Test_win_gotoid() v9.CheckDefAndScriptFailure(['win_gotoid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef +func Test_win_gotoid_in_mapping() + CheckScreendump + + if has('clipboard_working') + let @* = 'foo' + let lines =<< trim END + set cmdheight=2 + func On_click() + call win_gotoid(getmousepos().winid) + execute "norm! \<LeftMouse>" + endfunc + noremap <LeftMouse> <Cmd>call On_click()<CR> + + autocmd SafeState * echo 'reg = "' .. @* .. '"' + + call setline(1, range(20)) + set nomodified + botright new + call setline(1, range(21, 40)) + set nomodified + + func Click() + map <silent> <F3> :call test_setmouse(3, 1)<CR> + call feedkeys("\<F3>\<LeftMouse>\<LeftRelease>", "xt") + endfunc + END + call writefile(lines, 'Xgotoscript') + let buf = RunVimInTerminal('-S Xgotoscript', #{rows: 15, wait_for_ruler: 0}) + call VerifyScreenDump(buf, 'Test_win_gotoid_1', {}) + call term_sendkeys(buf, "3Gvl") + call VerifyScreenDump(buf, 'Test_win_gotoid_2', {}) + + call term_sendkeys(buf, ":call Click()\<CR>") + call VerifyScreenDump(buf, 'Test_win_gotoid_3', {}) + + call StopVimInTerminal(buf) + call delete('Xgotoscript') + endif +endfunc + def Test_win_id2tabwin() v9.CheckDefAndScriptFailure(['win_id2tabwin("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef diff --git a/src/version.c b/src/version.c index 285bced26d..f3f88125b7 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4785, +/**/ 4784, /**/ 4783, |