Patch 8.2.0902
Problem:    Using searchcount() in 'statusline' causes an error.
Solution:   Avoid saving/restoring the search patten recursively.
            (closes #6194)
Files:      src/search.c, src/testdir/test_search_stat.vim,
            src/testdir/dumps/Test_searchstat_4.dump


*** ../vim-8.2.0901/src/search.c        2020-06-03 22:57:03.949036909 +0200
--- src/search.c        2020-06-04 20:24:40.152570678 +0200
***************
*** 356,365 ****
      void
  save_last_search_pattern(void)
  {
!     if (did_save_last_search_spat != 0)
!       iemsg("did_save_last_search_spat is not zero");
!     else
!       ++did_save_last_search_spat;
  
      saved_last_search_spat = spats[RE_SEARCH];
      if (spats[RE_SEARCH].pat != NULL)
--- 356,364 ----
      void
  save_last_search_pattern(void)
  {
!     if (++did_save_last_search_spat != 1)
!       // nested call, nothing to do
!       return;
  
      saved_last_search_spat = spats[RE_SEARCH];
      if (spats[RE_SEARCH].pat != NULL)
***************
*** 371,382 ****
      void
  restore_last_search_pattern(void)
  {
!     if (did_save_last_search_spat != 1)
      {
!       iemsg("did_save_last_search_spat is not one");
        return;
      }
-     --did_save_last_search_spat;
  
      vim_free(spats[RE_SEARCH].pat);
      spats[RE_SEARCH] = saved_last_search_spat;
--- 370,383 ----
      void
  restore_last_search_pattern(void)
  {
!     if (--did_save_last_search_spat > 0)
!       // nested call, nothing to do
!       return;
!     if (did_save_last_search_spat != 0)
      {
!       iemsg("restore_last_search_pattern() called more often than 
save_last_search_pattern()");
        return;
      }
  
      vim_free(spats[RE_SEARCH].pat);
      spats[RE_SEARCH] = saved_last_search_spat;
*** ../vim-8.2.0901/src/testdir/test_search_stat.vim    2020-06-03 
22:57:03.949036909 +0200
--- src/testdir/test_search_stat.vim    2020-06-04 20:20:52.225283015 +0200
***************
*** 263,268 ****
--- 263,296 ----
    call assert_fails('echo searchcount("boo!")', 'E715:')
  endfunc
  
+ func Test_searchcount_in_statusline()
+   CheckScreendump
+ 
+   let lines =<< trim END
+     set shortmess-=S
+     call append(0, 'this is something')
+     function TestSearchCount() abort
+       let search_count = searchcount()
+       if !empty(search_count)
+       return '[' . search_count.current . '/' . search_count.total . ']'
+       else
+       return ''
+       endif
+     endfunction
+     set hlsearch
+     set laststatus=2 statusline+=%{TestSearchCount()}
+   END
+   call writefile(lines, 'Xsearchstatusline')
+   let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10})
+   call TermWait(buf)
+   call term_sendkeys(buf, "/something")
+   call VerifyScreenDump(buf, 'Test_searchstat_4', {})
+ 
+   call term_sendkeys(buf, "\<Esc>")
+   call StopVimInTerminal(buf)
+   call delete('Xsearchstatusline')
+ endfunc
+ 
  func Test_search_stat_foldopen()
    CheckScreendump
  
*** ../vim-8.2.0901/src/testdir/dumps/Test_searchstat_4.dump    2020-06-04 
20:55:03.164115129 +0200
--- src/testdir/dumps/Test_searchstat_4.dump    2020-06-04 20:24:52.468530841 
+0200
***************
*** 0 ****
--- 1,10 ----
+ |t+0&#ffffff0|h|i|s| |i|s| |s+1&&|o|m|e|t|h|i|n|g| +0&&@57
+ @75
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |[+3#0000000&|1|/|1|]| @69
+ |/+0&&|s|o|m|e|t|h|i|n|g> @64
*** ../vim-8.2.0901/src/version.c       2020-06-04 18:21:56.046395485 +0200
--- src/version.c       2020-06-04 19:38:17.997050203 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     902,
  /**/

-- 
A cow comes flying over the battlements,  lowing aggressively.  The cow
lands on GALAHAD'S PAGE, squashing him completely.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202006041856.054Iurxw815042%40masaka.moolenaar.net.

Raspunde prin e-mail lui