Patch 8.2.1147
Problem:    :confirm may happen in cooked mode. (Jason Franklin)
Solution:   Switch to raw mode before prompting. (Brandon Pfeifer)
Files:      src/message.c, src/testdir/test_excmd.vim


*** ../vim-8.2.1146/src/message.c       2020-06-10 14:16:30.102988393 +0200
--- src/message.c       2020-07-06 21:12:09.155913250 +0200
***************
*** 3652,3657 ****
--- 3652,3658 ----
      char_u    *hotkeys;
      int               c;
      int               i;
+     tmode_T   save_tmode;
  
  #ifndef NO_CONSOLE
      // Don't output anything in silent mode ("ex -s")
***************
*** 3683,3688 ****
--- 3684,3693 ----
      State = CONFIRM;
      setmouse();
  
+     // Ensure raw mode here.
+     save_tmode = cur_tmode;
+     settmode(TMODE_RAW);
+ 
      /*
       * Since we wait for a keypress, don't make the
       * user press RETURN as well afterwards.
***************
*** 3743,3748 ****
--- 3748,3754 ----
        vim_free(hotkeys);
      }
  
+     settmode(save_tmode);
      State = oldState;
      setmouse();
      --no_wait_return;
*** ../vim-8.2.1146/src/testdir/test_excmd.vim  2020-06-26 20:41:35.624844706 
+0200
--- src/testdir/test_excmd.vim  2020-07-06 21:24:45.317919404 +0200
***************
*** 189,237 ****
    CheckNotGui
    CheckRunVimInTerminal
  
!   call writefile(['foo1'], 'foo')
!   call writefile(['bar1'], 'bar')
  
    " Test for saving all the modified buffers
!   let buf = RunVimInTerminal('', {'rows': 20})
!   call term_sendkeys(buf, ":set nomore\n")
!   call term_sendkeys(buf, ":new foo\n")
!   call term_sendkeys(buf, ":call setline(1, 'foo2')\n")
!   call term_sendkeys(buf, ":new bar\n")
!   call term_sendkeys(buf, ":call setline(1, 'bar2')\n")
!   call term_sendkeys(buf, ":wincmd b\n")
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "A")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo2'], readfile('foo'))
!   call assert_equal(['bar2'], readfile('bar'))
  
    " Test for discarding all the changes to modified buffers
!   let buf = RunVimInTerminal('', {'rows': 20})
!   call term_sendkeys(buf, ":set nomore\n")
!   call term_sendkeys(buf, ":new foo\n")
!   call term_sendkeys(buf, ":call setline(1, 'foo3')\n")
!   call term_sendkeys(buf, ":new bar\n")
!   call term_sendkeys(buf, ":call setline(1, 'bar3')\n")
!   call term_sendkeys(buf, ":wincmd b\n")
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "D")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo2'], readfile('foo'))
!   call assert_equal(['bar2'], readfile('bar'))
  
    " Test for saving and discarding changes to some buffers
!   let buf = RunVimInTerminal('', {'rows': 20})
!   call term_sendkeys(buf, ":set nomore\n")
!   call term_sendkeys(buf, ":new foo\n")
!   call term_sendkeys(buf, ":call setline(1, 'foo4')\n")
!   call term_sendkeys(buf, ":new bar\n")
!   call term_sendkeys(buf, ":call setline(1, 'bar4')\n")
!   call term_sendkeys(buf, ":wincmd b\n")
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "N")
--- 189,246 ----
    CheckNotGui
    CheckRunVimInTerminal
  
!   call writefile(['foo1'], 'Xfoo')
!   call writefile(['bar1'], 'Xbar')
  
    " Test for saving all the modified buffers
!   let lines =<< trim END
!     set nomore
!     new Xfoo
!     call setline(1, 'foo2')
!     new Xbar
!     call setline(1, 'bar2')
!     wincmd b
!   END
!   call writefile(lines, 'Xscript')
!   let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "A")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo2'], readfile('Xfoo'))
!   call assert_equal(['bar2'], readfile('Xbar'))
  
    " Test for discarding all the changes to modified buffers
!   let lines =<< trim END
!     set nomore
!     new Xfoo
!     call setline(1, 'foo3')
!     new Xbar
!     call setline(1, 'bar3')
!     wincmd b
!   END
!   call writefile(lines, 'Xscript')
!   let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "D")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo2'], readfile('Xfoo'))
!   call assert_equal(['bar2'], readfile('Xbar'))
  
    " Test for saving and discarding changes to some buffers
!   let lines =<< trim END
!     set nomore
!     new Xfoo
!     call setline(1, 'foo4')
!     new Xbar
!     call setline(1, 'bar4')
!     wincmd b
!   END
!   call writefile(lines, 'Xscript')
!   let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
    call term_sendkeys(buf, ":confirm qall\n")
    call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard 
All, (C)ancel: ', term_getline(buf, 20))}, 1000)
    call term_sendkeys(buf, "N")
***************
*** 239,249 ****
    call term_sendkeys(buf, "Y")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo4'], readfile('foo'))
!   call assert_equal(['bar2'], readfile('bar'))
  
!   call delete('foo')
!   call delete('bar')
  endfunc
  
  func Test_confirm_cmd_cancel()
--- 248,259 ----
    call term_sendkeys(buf, "Y")
    call StopVimInTerminal(buf)
  
!   call assert_equal(['foo4'], readfile('Xfoo'))
!   call assert_equal(['bar2'], readfile('Xbar'))
  
!   call delete('Xscript')
!   call delete('Xfoo')
!   call delete('Xbar')
  endfunc
  
  func Test_confirm_cmd_cancel()
***************
*** 251,260 ****
    CheckRunVimInTerminal
  
    " Test for closing a window with a modified buffer
!   let buf = RunVimInTerminal('', {'rows': 20})
!   call term_sendkeys(buf, ":set nomore\n")
!   call term_sendkeys(buf, ":new\n")
!   call term_sendkeys(buf, ":call setline(1, 'abc')\n")
    call term_sendkeys(buf, ":confirm close\n")
    call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
          \ term_getline(buf, 20))}, 1000)
--- 261,273 ----
    CheckRunVimInTerminal
  
    " Test for closing a window with a modified buffer
!   let lines =<< trim END
!     set nomore
!     new
!     call setline(1, 'abc')
!   END
!   call writefile(lines, 'Xscript')
!   let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
    call term_sendkeys(buf, ":confirm close\n")
    call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
          \ term_getline(buf, 20))}, 1000)
***************
*** 267,272 ****
--- 280,322 ----
    call WaitForAssert({-> assert_match('^ *0,0-1         All$',
          \ term_getline(buf, 20))}, 1000)
    call StopVimInTerminal(buf)
+   call delete('Xscript')
+ endfunc
+ 
+ " The ":confirm" prompt was sometimes used with the terminal in cooked mode.
+ " This test verifies that a "\<CR>" character is NOT required to respond to a
+ " prompt from the ":conf q" and ":conf wq" commands.
+ func Test_confirm_q_wq()
+   CheckNotGui
+   CheckRunVimInTerminal
+ 
+   call writefile(['foo'], 'Xfoo')
+ 
+   let lines =<< trim END
+     set hidden nomore
+     call setline(1, 'abc')
+     edit Xfoo
+   END
+   call writefile(lines, 'Xscript')
+   let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
+   call term_sendkeys(buf, ":confirm q\n")
+   call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
+         \ term_getline(buf, 20))}, 1000)
+   call term_sendkeys(buf, 'C')
+   call WaitForAssert({-> assert_notmatch('^\[Y\]es, (N)o, (C)ancel: C*$',
+         \ term_getline(buf, 20))}, 1000)
+ 
+   call term_sendkeys(buf, ":edit Xfoo\n")
+   call term_sendkeys(buf, ":confirm wq\n")
+   call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
+         \ term_getline(buf, 20))}, 1000)
+   call term_sendkeys(buf, 'C')
+   call WaitForAssert({-> assert_notmatch('^\[Y\]es, (N)o, (C)ancel: C*$',
+         \ term_getline(buf, 20))}, 1000)
+   call StopVimInTerminal(buf)
+ 
+   call delete('Xscript')
+   call delete('Xfoo')
  endfunc
  
  " Test for the :print command
*** ../vim-8.2.1146/src/version.c       2020-07-06 21:03:02.589331536 +0200
--- src/version.c       2020-07-06 21:13:12.427748249 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1147,
  /**/

-- 
Our job was to build a computer information system for the branch banks.  We
were the perfect people for the job: Dean had seen a computer once, and I had
heard Dean talk about it.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202007061925.066JPLjM896480%40masaka.moolenaar.net.

Raspunde prin e-mail lui