Patch 9.0.1518
Problem:    Search stats not always visible when searching backwards.
Solution:   Do not display the top/bot message on top of the search stats.
            (Christian Brabandt, closes #12322, closes #12222)
Files:      src/option.h, src/search.c, src/testdir/test_search_stat.vim,
            src/testdir/dumps/Test_searchstat_back_1.dump,
            src/testdir/dumps/Test_searchstat_back_2.dump,
            src/testdir/dumps/Test_searchstat_back_3.dump


*** ../vim-9.0.1517/src/option.h        2023-02-25 11:59:28.866874078 +0000
--- src/option.h        2023-05-06 19:09:52.109728514 +0100
***************
*** 268,274 ****
  #define SHM_COMPLETIONSCAN  'C'               // completion scanning messages
  #define SHM_RECORDING 'q'             // short recording message
  #define SHM_FILEINFO  'F'             // no file info messages
! #define SHM_SEARCHCOUNT  'S'          // search stats: '[1/10]'
  #define SHM_POSIX       "AS"          // POSIX value
  #define SHM_ALL               "rmfixlnwaWtToOsAIcCqFS" // all possible flags 
for 'shm'
  #define SHM_LEN               30              // max length of all flags 
together
--- 268,274 ----
  #define SHM_COMPLETIONSCAN  'C'               // completion scanning messages
  #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_POSIX       "AS"          // POSIX value
  #define SHM_ALL               "rmfixlnwaWtToOsAIcCqFS" // all possible flags 
for 'shm'
  #define SHM_LEN               30              // max length of all flags 
together
*** ../vim-9.0.1517/src/search.c        2023-04-29 21:38:00.567105309 +0100
--- src/search.c        2023-05-06 19:12:17.829440065 +0100
***************
*** 1089,1095 ****
  
            /*
             * If 'wrapscan' is set we continue at the other end of the file.
!            * If 'shortmess' does not contain 's', we give a message.
             * This message is also remembered in keep_msg for when the screen
             * is redrawn. The keep_msg is cleared whenever another message is
             * written.
--- 1089,1097 ----
  
            /*
             * If 'wrapscan' is set we continue at the other end of the file.
!            * If 'shortmess' does not contain 's', we give a message, but
!            * only, if we won't show the search stat later anyhow,
!            * (so SEARCH_COUNT must be absent).
             * This message is also remembered in keep_msg for when the screen
             * is redrawn. The keep_msg is cleared whenever another message is
             * written.
***************
*** 1098,1104 ****
                lnum = buf->b_ml.ml_line_count;
            else
                lnum = 1;
!           if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
                give_warning((char_u *)_(dir == BACKWARD
                                          ? top_bot_msg : bot_top_msg), TRUE);
            if (extra_arg != NULL)
--- 1100,1108 ----
                lnum = buf->b_ml.ml_line_count;
            else
                lnum = 1;
!           if (!shortmess(SHM_SEARCH)
!                   && shortmess(SHM_SEARCHCOUNT)
!                   && (options & SEARCH_MSG))
                give_warning((char_u *)_(dir == BACKWARD
                                          ? top_bot_msg : bot_top_msg), TRUE);
            if (extra_arg != NULL)
***************
*** 3237,3244 ****
        lbuf = curbuf;
      }
  
      if (EQUAL_POS(lastpos, *cursor_pos) && !wraparound
!               && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0))
        cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;
      else
      {
--- 3241,3250 ----
        lbuf = curbuf;
      }
  
+     // when searching backwards and having jumped to the first occurrence,
+     // cur must remain greater than 1
      if (EQUAL_POS(lastpos, *cursor_pos) && !wraparound
!               && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 1))
        cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;
      else
      {
*** ../vim-9.0.1517/src/testdir/test_search_stat.vim    2023-01-31 
21:13:35.070100023 +0000
--- src/testdir/test_search_stat.vim    2023-05-06 19:09:52.113728509 +0100
***************
*** 153,159 ****
      let g:a = execute(':unsilent :norm! n')
      let stat = 'W \[20/1\]'
      call assert_match(pat .. stat, g:a)
-     call assert_match('search hit BOTTOM, continuing at TOP', g:a)
      set norl
    endif
  
--- 153,158 ----
***************
*** 164,170 ****
    let g:a = execute(':unsilent :norm! N')
    let stat = 'W \[20/20\]'
    call assert_match(pat .. stat, g:a)
-   call assert_match('search hit TOP, continuing at BOTTOM', g:a)
    call assert_match('W \[20/20\]', Screenline(&lines))
  
    " normal, no match
--- 163,168 ----
***************
*** 432,436 ****
--- 430,462 ----
    call StopVimInTerminal(buf)
  endfunc
  
+ func Test_search_stat_backwards()
+   CheckScreendump
+ 
+   let lines =<< trim END
+     set shm-=S
+     call setline(1, ['test', ''])
+   END
+   call writefile(lines, 'Xsearchstat_back', 'D')
+ 
+   let buf = RunVimInTerminal('-S Xsearchstat_back', #{rows: 10})
+   call term_sendkeys(buf, "*")
+   call TermWait(buf)
+   call VerifyScreenDump(buf, 'Test_searchstat_back_1', {})
+ 
+   call term_sendkeys(buf, "N")
+   call TermWait(buf)
+   call VerifyScreenDump(buf, 'Test_searchstat_back_2', {})
+ 
+   call term_sendkeys(buf, ":set shm+=S\<cr>N")
+   call TermWait(buf)
+   " shows "Search Hit Bottom.."
+   call VerifyScreenDump(buf, 'Test_searchstat_back_3', {})
+ 
+   call term_sendkeys(buf, "\<esc>:qa\<cr>")
+   call TermWait(buf)
+ 
+   call StopVimInTerminal(buf)
+ endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1517/src/testdir/dumps/Test_searchstat_back_1.dump       
2023-05-06 19:19:28.408654127 +0100
--- src/testdir/dumps/Test_searchstat_back_1.dump       2023-05-06 
19:09:52.113728509 +0100
***************
*** 0 ****
--- 1,10 ----
+ >t+0&#ffffff0|e|s|t| @70
+ @75
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |/+0#0000000&|\|<|t|e|s|t|\|>| @30|[|1|/|1|]| @11|1|,|1| @10|A|l@1| 
*** ../vim-9.0.1517/src/testdir/dumps/Test_searchstat_back_2.dump       
2023-05-06 19:19:28.412654120 +0100
--- src/testdir/dumps/Test_searchstat_back_2.dump       2023-05-06 
19:09:52.113728509 +0100
***************
*** 0 ****
--- 1,10 ----
+ >t+0&#ffffff0|e|s|t| @70
+ @75
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |?+0#0000000&|\|<|t|e|s|t|\|>| @30|[|1|/|1|]| @11|1|,|1| @10|A|l@1| 
*** ../vim-9.0.1517/src/testdir/dumps/Test_searchstat_back_3.dump       
2023-05-06 19:19:28.420654105 +0100
--- src/testdir/dumps/Test_searchstat_back_3.dump       2023-05-06 
19:09:52.113728509 +0100
***************
*** 0 ****
--- 1,10 ----
+ >t+0&#ffffff0|e|s|t| @70
+ @75
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |s+0#e000002&|e|a|r|c|h| |h|i|t| |T|O|P|,| |c|o|n|t|i|n|u|i|n|g| |a|t| 
|B|O|T@1|O|M| +0#0000000&@20|1|,|1| @10|A|l@1| 
*** ../vim-9.0.1517/src/version.c       2023-05-06 18:07:11.155286970 +0100
--- src/version.c       2023-05-06 19:15:18.601100525 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1518,
  /**/

-- 
login: yes
password: I don't know, please tell me
password is incorrect
login: yes
password: incorrect

 /// 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/20230506182049.888051C1B21%40moolenaar.net.

Raspunde prin e-mail lui