On Sa, 04 Mai 2019, Bram Moolenaar wrote:

> Patch 8.1.1270
> Problem:    Cannot see current match position.
> Solution:   Show "3/44" when using the "n" command and "S" is not in
>             'shortmess'. (Christian Brabandt, closes #4317)
> Files:            runtime/doc/options.txt, runtime/doc/pattern.txt, 
> src/option.c,
>             src/option.h, src/search.c, src/testdir/Make_all.mak,
>             src/testdir/test_search_stat.vim

I noticed one problem. I usually have n mapped to nzv and noticed that 
after a search wrap, the count and matches are no longer displayed. I 
think this happens, because the search_stat function uses the 
`SEARCH_PEEK` flag and aborts once it notices that there are more 
characters comming from a mapping. Don't ask me, why this does not 
happen the first time :(

So here is a patch with a test, note the test won't probably not fail 
currently, but I figured it should be added nonetheless. 

diff --git a/src/search.c b/src/search.c
index dd5519e79..74a35e9f5 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4958,7 +4958,7 @@ search_stat(
        profile_setlimit(20L, &start);
 #endif
        while (!got_int && searchit(curwin, curbuf, &lastpos, NULL,
-                                  FORWARD, NULL, 1, SEARCH_PEEK + SEARCH_KEEP,
+                                  FORWARD, NULL, 1, SEARCH_KEEP,
                                     RE_LAST, (linenr_T)0, NULL, NULL) != FAIL)
        {
 #ifdef FEAT_RELTIME
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index 57dad81b8..797d58244 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -105,6 +105,26 @@ func! Test_search_stat()
     call assert_false(1)
   endtry

+  " 11) normal, n comes from a mapping
+  nnoremap n nzv
+  call cursor(1,1)
+  let @/ = 'foobar'
+  let pat = '/foobar\s\+'
+  let g:a = execute(':unsilent :norm n')
+  " g:a will contain several lines
+  let g:b = split(g:a, "\n")[-1]
+  let stat = '\[2/20\]'
+  call assert_match(pat .. stat, g:b)
+  unmap n
+
+  " 11) normal, but silent
+  call cursor(1,1)
+  let @/ = 'foobar'
+  let pat = '/foobar\s\+'
+  let g:a = execute(':norm! n')
+  let stat = '\[2/20\]'
+  call assert_notmatch(pat .. stat, g:a)
+
   " close the window
   set shortmess+=S
   bwipe!


Mit freundlichen Grüßen
Christian
-- 
Lebenskünstler leben von den Zinsen eines nicht vorhandenen Kapitals.
                -- Stanislaw Jerzy Lec

-- 
-- 
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/20190507083123.GG31339%40256bit.org.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui