Patch 9.0.0569
Problem:    Cannot easily get out when using "vim file | grep word".
Solution:   Without changes let CTRL-C exit Vim.  Otherwise give a message on
            stderr. (closes #11209)
Files:      src/normal.c, src/testdir/test_startup.vim


*** ../vim-9.0.0568/src/normal.c        2022-09-16 20:50:44.968907925 +0100
--- src/normal.c        2022-09-24 12:06:15.056480256 +0100
***************
*** 6793,6802 ****
                && !VIsual_active
                && no_reason)
        {
            if (anyBufIsChanged())
!               msg(_("Type  :qa!  and press <Enter> to abandon all changes and 
exit Vim"));
            else
!               msg(_("Type  :qa  and press <Enter> to exit Vim"));
        }
  
        if (restart_edit != 0)
--- 6793,6825 ----
                && !VIsual_active
                && no_reason)
        {
+           int out_redir = !stdout_isatty
+ #ifdef FEAT_GUI
+                               && !gui.in_use
+ #endif
+                               ;
+           // The user may accidentally do "vim file | grep word" and then
+           // CTRL-C doesn't show anything.  With a changed buffer give the
+           // message on stderr.  Without any changes might as well exit.
            if (anyBufIsChanged())
!           {
!               char *ms = _("Type  :qa!  and press <Enter> to abandon all 
changes and exit Vim");
! 
!               if (out_redir)
!                   mch_errmsg(ms);
!               else
!                   msg(ms);
!           }
            else
!           {
!               if (out_redir)
!               {
!                   got_int = FALSE;
!                   do_cmdline_cmd((char_u *)"qa");
!               }
!               else
!                   msg(_("Type  :qa  and press <Enter> to exit Vim"));
!           }
        }
  
        if (restart_edit != 0)
*** ../vim-9.0.0568/src/testdir/test_startup.vim        2022-09-09 
17:09:32.204881239 +0100
--- src/testdir/test_startup.vim        2022-09-24 12:43:38.986882511 +0100
***************
*** 1109,1114 ****
--- 1109,1137 ----
    call delete('Xvimout')
  endfunc
  
+ " Test quitting with CTRL-C when output is redirected.
+ func Test_redirect_Ctrl_C()
+   CheckUnix
+   CheckNotGui
+   CheckRunVimInTerminal
+ 
+   let buf = Run_shell_in_terminal({})
+   " Wait for the shell to display a prompt
+   call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
+ 
+   call term_sendkeys(buf, GetVimProg() .. " | grep word\<CR>")
+   call WaitForAssert({-> assert_match("Output is not to a terminal", 
getline(1, 4)->join())})
+   " wait for the hard coded delay, otherwise the CTRL-C interrupts startup
+   sleep 2
+   call term_sendkeys(buf, "\<C-C>")
+   sleep 100m
+   call term_sendkeys(buf, "exit\<CR>")
+   call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
+ 
+   exe buf . 'bwipe!'
+   unlet g:job
+ endfunc
+ 
  
  " Test for the "-w scriptout" argument
  func Test_w_arg()
*** ../vim-9.0.0568/src/version.c       2022-09-24 11:30:38.373605018 +0100
--- src/version.c       2022-09-24 11:55:06.055877714 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     569,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
159. You get excited whenever discussing your hard drive.

 /// 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/20220924115151.106141C0728%40moolenaar.net.

Raspunde prin e-mail lui