Tuesday, August 27, 2019

Re: Mapping erases search count message

On 2019-08-28, Tony Mechelynck wrote:
> On Wed, Aug 28, 2019 at 7:31 AM Gary Johnson wrote:
> >
> > I just tried exposing the search count message by removing 'S' from
> > 'shortmess', but I couldn't see it. I discovered that it is hidden,
> > erased and/or not updated by a couple of my mappings.
> >
> > nnoremap <silent> n nzv:call AdjCursor()<CR>
> > nnoremap <silent> N Nzv:call AdjCursor()<CR>
> >
> > Here is a simple experiment that demonstrates the problem. Create
> > a file, test.vim, that contains the following.
> >
> > set shortmess-=S
> > nnoremap <silent> n n
> > help map.txt
> >
> > Open a standard-sized, 80x24 terminal, and in it run
> >
> > $ vim -N -u NONE -i NONE -S test.vim
> >
> > Then search for "command":
> >
> > /command
> >
> > After hitting Enter, the cursor will be at the start of "commands"
> > on line 7 and the command line will contain this:
> >
> > /command [1/>99]
> >
> > After hitting 'n', the cursor advances to line 13 and the command
> > line stays the same, even showing "[1/>99]" when it should be
> > showing "[2/>99]".
> >
> > Another 'n' advances the cursor to line 17, the screen scrolls
> > up so that that line is at the bottom of the window, and the command
> > line is empty--no search count message at all.
> >
> > I would think that <silent> would prevent the mapping from
> > disturbing the command line, in which case this is a bug.
> >
> > If it's not a bug, then is there some way of defining a mapping that
> > does not interfere with the search count message, or some way of
> > restoring that message at the end of a mapping?
> >
> > Regards,
> > Gary
>
> I can't reproduce the problem.
>
> What I get by hitting n after applying your mappings is:
>
> E117: Unknown function: AdjCursor
>
> With no mappings, the count is of course corectly shown.

Yes, if you were to use those first two mappings without the
AdjCursor() function defined, I would expect them to fail as you
describe. You can avoid that by defining AdjCursor() as an empty
function. Alternatively, you can use the mapping that I intended
for you to use to demonstrate the problem, the one defined in
test.vim.

Regards,
Gary

--
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190828061339.GA26834%40phoenix.

No comments:

Post a Comment