Patch 8.2.3671
Problem:    Restarting Insert mode in prompt buffer too often when a callback
            switches windows and comes back. (Sean Dewar)
Solution:   Do not set "restart_edit" when already in Insert mode.
Files:      src/window.c, src/testdir/test_prompt_buffer.vim


*** ../vim-8.2.3670/src/window.c        2021-11-20 13:45:37.810729599 +0000
--- src/window.c        2021-11-25 13:03:47.430481302 +0000
***************
*** 2268,2275 ****
        stop_insert_mode = FALSE;
  
      // When entering the prompt window restart Insert mode if we were in 
Insert
!     // mode when we left it.
!     restart_edit = win->w_buffer->b_prompt_insert;
  }
  #endif
  
--- 2268,2276 ----
        stop_insert_mode = FALSE;
  
      // When entering the prompt window restart Insert mode if we were in 
Insert
!     // mode when we left it and not already in Insert mode.
!     if ((State & INSERT) == 0)
!       restart_edit = win->w_buffer->b_prompt_insert;
  }
  #endif
  
*** ../vim-8.2.3670/src/testdir/test_prompt_buffer.vim  2021-06-10 
20:52:11.813718366 +0100
--- src/testdir/test_prompt_buffer.vim  2021-11-25 12:52:47.600676708 +0000
***************
*** 39,44 ****
--- 39,48 ----
        \ '  set nomodified',
        \ 'endfunc',
        \ '',
+       \ 'func SwitchWindows()',
+       \ '  call timer_start(0, {-> execute("wincmd p|wincmd p", "")})',
+       \ 'endfunc',
+       \ '',
        \ 'call setline(1, "other buffer")',
        \ 'set nomodified',
        \ 'new',
***************
*** 97,102 ****
--- 101,127 ----
  
    call StopVimInTerminal(buf)
    call delete(scriptName)
+ endfunc
+ 
+ func Test_prompt_switch_windows()
+   call CanTestPromptBuffer()
+   let scriptName = 'XpromptSwitchWindows'
+   call WriteScript(scriptName)
+ 
+   let buf = RunVimInTerminal('-S ' . scriptName, {'rows': 12})
+   call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
+   call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))})
+ 
+   call term_sendkeys(buf, "\<C-O>:call SwitchWindows()\<CR>")
+   call term_wait(buf, 50)
+   call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))})
+ 
+   call term_sendkeys(buf, "\<Esc>")
+   call term_wait(buf, 50)
+   call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 12))})
+ 
+   call StopVimInTerminal(buf)
+   call delete(scriptName)
  endfunc
  
  func Test_prompt_garbage_collect()
*** ../vim-8.2.3670/src/version.c       2021-11-25 11:16:43.141318500 +0000
--- src/version.c       2021-11-25 11:41:28.790704089 +0000
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     3671,
  /**/

-- 
No man may purchase alcohol without written consent from his wife.
                [real standing law in Pennsylvania, United States of America]

 /// 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/20211125130534.E5E161C0A05%40moolenaar.net.

Raspunde prin e-mail lui