]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0425: Cannot silence undo/redo messages v9.2.0425
authorShougo Matsushita <Shougo.Matsu@gmail.com>
Fri, 1 May 2026 14:54:56 +0000 (14:54 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 1 May 2026 14:54:56 +0000 (14:54 +0000)
Problem:  Cannot silence undo/redo messages
Solution: Add "u" flag to 'shortmess' option
          (Shougo Matsushita).

fixes:  #20049
closes: #20107

Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
runtime/doc/tags
runtime/doc/version9.txt
src/option.h
src/testdir/test_messages.vim
src/undo.c
src/version.c

index 3576e174b76c5c6d5255e0ad1007b08b926c3b24..d9dbcd8336ac96e00c169617685432d3203f3b54 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.2.  Last change: 2026 Apr 29
+*options.txt*  For Vim version 9.2.  Last change: 2026 May 01
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -8044,6 +8044,9 @@ A jump table for the options with a short description can be found at |Q_op|.
                search count statistics.  The maximum limit can be set with
                the 'maxsearchcount' option, see also |searchcount()|
                function.
+         u     don't give undo and redo messages like                  *shm-u*
+               "1 line less; before #1  1 second ago", "Already at oldest
+               change" or "Already at newest change"
 
        This gives you the opportunity to avoid that a change between buffers
        requires you to hit <Enter>, but still gives as useful a message as
index 3bc6f71554787d776856f3765fb48bb1917bf50c..4ad699ed55db93c10bb1b3c2713f1bd1c92a53dc 100644 (file)
@@ -10331,6 +10331,7 @@ shm-q   options.txt     /*shm-q*
 shm-r  options.txt     /*shm-r*
 shm-s  options.txt     /*shm-s*
 shm-t  options.txt     /*shm-t*
+shm-u  options.txt     /*shm-u*
 shm-w  options.txt     /*shm-w*
 shm-x  options.txt     /*shm-x*
 short-name-changed     version4.txt    /*short-name-changed*
index 9516ecd1250da1451a29aaa10a93830bd60690c3..ca69850e05febcb2cf1f6e6596a7196ca6e60615 100644 (file)
@@ -1,4 +1,4 @@
-*version9.txt* For Vim version 9.2.  Last change: 2026 Apr 29
+*version9.txt* For Vim version 9.2.  Last change: 2026 May 01
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -52621,6 +52621,7 @@ Other ~
 - Added the "noinsert" value to the 'wildmode' option for symmetry with the
   'completeopt' option
 - Channel can handle |Blob| messages |channel-open-options|.
+- Added the "u" flag to 'shortmess' to silence undo/redo messages: |shm-u|
 
 Platform specific ~
 -----------------
index cda49a4af50839f5e97f223d1fd21c887b61ffef..a4359a2590dea72b1c2c57acef0bfae4c8e350b4 100644 (file)
@@ -277,8 +277,9 @@ typedef enum {
 #define SHM_RECORDING  'q'             // short recording message
 #define SHM_FILEINFO   'F'             // no file info messages
 #define SHM_SEARCHCOUNT  'S'           // no search stats: '[1/10]'
+#define SHM_UNDO       'u'             // undo messages
 #define SHM_POSIX       "AS"           // POSIX value
-#define SHM_ALL                "rmfixlnwaWtToOsAIcCqFS" // all possible flags for 'shm'
+#define SHM_ALL                "rmfixlnwaWtToOsAIcCqFSu" // all possible flags for 'shm'
 #define SHM_LEN                30              // max length of all flags together
                                        // plus a NUL character
 
index 80996cfad6e13e0e4c53f6bbef2249c8fd7a2af1..2e5a16e4b810e2daff0834f13adbfd675b1c0200 100644 (file)
@@ -837,4 +837,69 @@ func Test_fileinfo_after_last_bd()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_undo_messages()
+  new
+
+  " Normal undo/redo messages
+  redir => result
+  call setline(1, 'foo')
+  undo
+  undo
+  redo
+  redo
+  redir END
+  let msg_list = split(result, "\n")
+  call assert_match("^1 line less; before #1", msg_list[0])
+  call assert_equal("Already at oldest change", msg_list[1])
+  call assert_match("^1 more line; after #1", msg_list[2])
+  call assert_equal("Already at newest change", msg_list[3])
+
+  " Ignore undo/redo messages
+  redir => result
+  set shortmess+=u
+  call setline(1, 'foo')
+  undo
+  undo
+  redo
+  redo
+  redir END
+  let msg_list = split(result, "\n")
+  call assert_equal([], msg_list)
+  set shortmess&
+
+  " undo_time() path: :earlier and :later go through a separate
+  " message site than u_doit(); make sure SHM_UNDO suppresses it too.
+  enew!
+  call setline(1, 'a')
+  call setline(1, 'b')
+  call setline(1, 'c')
+
+  redir => result
+  earlier 1
+  earlier 999
+  earlier 999
+  later 1
+  later 999
+  redir END
+  let msg_list = split(result, "\n")
+  call assert_match('^1 line less; before #', msg_list[0])
+  call assert_match('^1 changes; before #', msg_list[1])
+  call assert_match('^1 changes; before #', msg_list[2])
+  call assert_match('^1 more line; after #', msg_list[3])
+  call assert_equal('Already at newest change', msg_list[4])
+
+  set shortmess+=u
+  redir => result
+  earlier 1
+  earlier 999
+  later 1
+  later 999
+  later 999
+  redir END
+  call assert_equal([], split(result, "\n"))
+
+  set shortmess&
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 170eaac47694ae38c32c38ec6267040027af80c8..ac38a8bf21c7be52ea3750737750ba811e28c3ab 100644 (file)
@@ -2262,7 +2262,8 @@ u_doit(int startcount)
                beep_flush();
                if (count == startcount - 1)
                {
-                   msg(_("Already at oldest change"));
+                   if (!shortmess(SHM_UNDO))
+                       msg(_("Already at oldest change"));
                    return;
                }
                break;
@@ -2277,7 +2278,8 @@ u_doit(int startcount)
                beep_flush();   // nothing to redo
                if (count == startcount - 1)
                {
-                   msg(_("Already at newest change"));
+                   if (!shortmess(SHM_UNDO))
+                       msg(_("Already at newest change"));
                    return;
                }
                break;
@@ -2530,10 +2532,13 @@ undo_time(
 
        if (closest == closest_start)
        {
-           if (step < 0)
-               msg(_("Already at oldest change"));
-           else
-               msg(_("Already at newest change"));
+           if (!shortmess(SHM_UNDO))
+           {
+               if (step < 0)
+                   msg(_("Already at oldest change"));
+               else
+                   msg(_("Already at newest change"));
+           }
            return;
        }
 
@@ -2996,7 +3001,8 @@ u_undo_end(
 #endif
 
     if (global_busy        // no messages now, wait until global is finished
-           || !messaging())  // 'lazyredraw' set, don't do messages now
+           || !messaging() // 'lazyredraw' set, don't do messages now
+           || shortmess(SHM_UNDO))
        return;
 
     if (curbuf->b_ml.ml_flags & ML_EMPTY)
index 837b453d10c2536ba4e6e7cb213fbfe8cd0e9525..41086657949b8b418288b7c7144e862150511104 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    425,
 /**/
     424,
 /**/