On Mo, 02 Sep 2019, Bram Moolenaar wrote:

> 
> Christian wrote:
> 
> > On Fr, 30 Aug 2019, Bram Moolenaar wrote:
> > 
> > > Thanks.  Yes, I think we should do this.  But the allocation should
> > > probably be done differently, it looks like with cmd_silent set it still
> > > computes the size of the command.  This will require some more "if"
> > > statements, but makes the size computation more accurate.
> > 
> > Well, yeah I thought this wouldn't hurt.
> > 
> > So how about the attached patch then? It will simply use all available 
> > space in the command line. Not sure this is correct however.
> 
> It's tricky with all the conditions.  But it looks OK.  All tests pass.
> Let's include this and check that nothing goes wrong.  Can we cover this
> with a test?

Apologizes, the last patch was wrong and caused a strtrunc message 
('...')  

Perhaps we don't even need the added condition `|| cmd_silent` at all?

Here is a fix including a test.

diff --git a/src/search.c b/src/search.c
index 758c4ef1a..ee66052a9 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1391,7 +1391,7 @@ do_search(
                // search stat.  Use all the space available, so that the
                // search state is right aligned.  If there is not enough space
                // msg_strtrunc() will shorten in the middle.
-               if (msg_scrolled != 0 || cmd_silent)
+               if (msg_scrolled != 0 && !cmd_silent)
                    // Use all the columns.
                    len = (int)(Rows - msg_row) * Columns - 1;
                else
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index cf36f3214..f23952915 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -160,7 +160,27 @@ func! Test_search_stat()
   let stat = '\[1/2\]'
   call assert_notmatch(pat .. stat, g:a)

-  " close the window
+  " normal, n comes from a silent mapping
+  " First test a normal mapping, then a silent mapping
+  call cursor(1,1)
+  nnoremap n n
+  let @/ = 'find this'
+  let pat = '/find this\s\+'
+  let g:a = execute(':unsilent :norm n')
+  let g:b = split(g:a, "\n")[-1]
+  let stat = '\[1/2\]'
+  call assert_match(pat .. stat, g:b)
+  nnoremap <silent> n n
+  call cursor(1,1)
+  let g:a = execute(':unsilent :norm n')
+  let g:b = split(g:a, "\n")[-1]
+  let stat = '\[1/2\]'
+  call assert_notmatch(pat .. stat, g:b)
+  call assert_match(stat, g:b)
+  unmap n
+
+  " Clean up
   set shortmess+=S
+  " close the window
   bwipe!
 endfunc


Best,
Christian
-- 
Sitzt eine Spinne auf dem Klo, wird man des Lebens nicht mehr froh.

-- 
-- 
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20190903073725.GN25942%40256bit.org.

Reply via email to