Patch 8.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)
Files:      src/evalwindow.c, src/testdir/test_vim9_builtin.vim,
            src/testdir/dumps/Test_win_gotoid_1.dump,
            src/testdir/dumps/Test_win_gotoid_2.dump,
            src/testdir/dumps/Test_win_gotoid_3.dump


*** ../vim-8.2.4784/src/evalwindow.c    2022-04-04 15:16:50.738014123 +0100
--- src/evalwindow.c    2022-04-18 18:26:36.074575179 +0100
***************
*** 817,822 ****
--- 817,825 ----
      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;
*** ../vim-8.2.4784/src/testdir/test_vim9_builtin.vim   2022-04-05 
21:40:32.111458253 +0100
--- src/testdir/test_vim9_builtin.vim   2022-04-18 18:30:54.582512129 +0100
***************
*** 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,4498 ****
--- 4494,4539 ----
    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
*** ../vim-8.2.4784/src/testdir/dumps/Test_win_gotoid_1.dump    2022-04-18 
18:29:55.790529340 +0100
--- src/testdir/dumps/Test_win_gotoid_1.dump    2022-04-18 17:59:20.022712284 
+0100
***************
*** 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
*** ../vim-8.2.4784/src/testdir/dumps/Test_win_gotoid_2.dump    2022-04-18 
18:29:55.794529337 +0100
--- src/testdir/dumps/Test_win_gotoid_2.dump    2022-04-18 18:01:58.770720539 
+0100
***************
*** 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
*** ../vim-8.2.4784/src/testdir/dumps/Test_win_gotoid_3.dump    2022-04-18 
18:29:55.798529339 +0100
--- src/testdir/dumps/Test_win_gotoid_3.dump    2022-04-18 18:17:59.290647185 
+0100
***************
*** 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
*** ../vim-8.2.4784/src/version.c       2022-04-18 16:14:06.435897246 +0100
--- src/version.c       2022-04-18 18:26:24.662576850 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4785,
  /**/

-- 
Anyone who is capable of getting themselves made President should on no
account be allowed to do the job.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220418173248.99DB81C0796%40moolenaar.net.

Raspunde prin e-mail lui