patch 9.2.0425: Cannot silence undo/redo messages

Commit: 
https://github.com/vim/vim/commit/d25f8d1b2c6e0cbd390a36884c95edc88f1b3d69
Author: Shougo Matsushita <[email protected]>
Date:   Fri May 1 14:54:56 2026 +0000

    patch 9.2.0425: Cannot silence undo/redo messages
    
    Problem:  Cannot silence undo/redo messages
    Solution: Add "u" flag to 'shortmess' option
              (Shougo Matsushita).
    
    fixes:  #20049
    closes: #20107
    
    Signed-off-by: Shougo Matsushita <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 3576e174b..d9dbcd833 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -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
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 3bc6f7155..4ad699ed5 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -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*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 9516ecd12..ca69850e0 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -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 ~
 -----------------
diff --git a/src/option.h b/src/option.h
index cda49a4af..a4359a259 100644
--- a/src/option.h
+++ b/src/option.h
@@ -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
 
diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim
index 80996cfad..2e5a16e4b 100644
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -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, "
")
+  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, "
")
+  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, "
")
+  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, "
"))
+
+  set shortmess&
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/undo.c b/src/undo.c
index 170eaac47..ac38a8bf2 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -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)
diff --git a/src/version.c b/src/version.c
index 837b453d1..410866579 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    425,
 /**/
     424,
 /**/

-- 
-- 
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 visit 
https://groups.google.com/d/msgid/vim_dev/E1wIq36-000cPR-Sm%40256bit.org.

Raspunde prin e-mail lui