Patch 9.0.1439
Problem:    Start Insert mode when accessing a hidden prompt buffer.
Solution:   Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst,
            closes #12148, closes #12147)
Files:      src/autocmd.c, src/window.c, src/proto/window.pro,
            src/testdir/test_prompt_buffer.vim


*** ../vim-9.0.1438/src/autocmd.c       2023-03-12 21:20:51.437254187 +0000
--- src/autocmd.c       2023-04-02 22:04:14.918501302 +0100
***************
*** 1657,1663 ****
            }
        }
  win_found:
! 
        // Remove the window and frame from the tree of frames.
        (void)winframe_remove(curwin, &dummy, NULL);
        win_remove(curwin, NULL);
--- 1657,1666 ----
            }
        }
  win_found:
! #ifdef FEAT_JOB_CHANNEL
!       // May need to stop Insert mode if we were in a prompt buffer.
!       leaving_window(curwin);
! #endif
        // Remove the window and frame from the tree of frames.
        (void)winframe_remove(curwin, &dummy, NULL);
        win_remove(curwin, NULL);
*** ../vim-9.0.1438/src/window.c        2023-03-07 17:13:47.321107768 +0000
--- src/window.c        2023-04-02 21:53:59.557421392 +0100
***************
*** 2292,2298 ****
  }
  
  #ifdef FEAT_JOB_CHANNEL
!     static void
  leaving_window(win_T *win)
  {
      // Only matters for a prompt window.
--- 2292,2298 ----
  }
  
  #ifdef FEAT_JOB_CHANNEL
!     void
  leaving_window(win_T *win)
  {
      // Only matters for a prompt window.
*** ../vim-9.0.1438/src/proto/window.pro        2022-11-22 12:40:44.062427876 
+0000
--- src/proto/window.pro        2023-04-02 22:03:45.410605841 +0100
***************
*** 13,18 ****
--- 13,19 ----
  int make_windows(int count, int vertical);
  void win_move_after(win_T *win1, win_T *win2);
  void win_equal(win_T *next_curwin, int current, int dir);
+ void leaving_window(win_T *win);
  void entering_window(win_T *win);
  void curwin_init(void);
  void close_windows(buf_T *buf, int keep_curwin);
*** ../vim-9.0.1438/src/testdir/test_prompt_buffer.vim  2022-10-06 
19:49:09.561466199 +0100
--- src/testdir/test_prompt_buffer.vim  2023-04-02 22:03:09.246740858 +0100
***************
*** 252,255 ****
--- 252,293 ----
    call StopVimInTerminal(buf)
  endfunc
  
+ func Test_prompt_appending_while_hidden()
+   call CanTestPromptBuffer()
+ 
+   let script =<< trim END
+       new prompt
+       set buftype=prompt
+       set bufhidden=hide
+ 
+       func s:TextEntered(text)
+           if a:text == 'exit'
+               close
+           endif
+           echowin 'Entered:' a:text
+       endfunc
+       call prompt_setcallback(bufnr(), function('s:TextEntered'))
+ 
+       func DoAppend()
+         call appendbufline('prompt', '$', 'Test')
+       endfunc
+   END
+   call writefile(script, 'XpromptBuffer', 'D')
+ 
+   let buf = RunVimInTerminal('-S XpromptBuffer', {'rows': 10})
+   call TermWait(buf)
+ 
+   call term_sendkeys(buf, "asomething\<CR>")
+   call TermWait(buf)
+ 
+   call term_sendkeys(buf, "exit\<CR>")
+   call TermWait(buf)
+ 
+   call term_sendkeys(buf, ":call DoAppend()\<CR>")
+   call TermWait(buf)
+   call assert_notmatch('-- INSERT --', term_getline(buf, 10))
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1438/src/version.c       2023-04-02 20:29:33.741597887 +0100
--- src/version.c       2023-04-02 21:56:32.396906337 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1439,
  /**/

-- 
    With sufficient thrust, pigs fly just fine.
                   -- RFC 1925

 /// 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/20230402210636.96FC11C03DE%40moolenaar.net.

Raspunde prin e-mail lui