Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ZLE Vi-mode: visual mode selection doesn't match the characters highlighted



Doron Behar wrote:
> I'm having a small inconvenience with the way characters are highlighted
> in visual mode.
>
> Say my $BUFFER has the following text, current $KEYMAP is "vicmd", and
> the cursor is located where ^ is:

>     ZSH is the best shell
>               ^
>               -----            (selected characters)

> The problem is, that only the 3 characters ("bes") are highlighted so
> it's not clear what characters exactly are selected.

I can't reproduce this. Could you perhaps try with your setup/plugins
disabled by starting from `zsh -df'. It may also be worth trying a
different terminal emulator. If you use a vi command such as x or c, is
the full region affected?

If the position of the actual cursor is not highlighted, I would
suspect that your terminal emulator uses standout (reverse video)
for the cursor which combined with the default zsh use of standout
for the region reverses it back to the original state. What do you
have in the zle_highlight array? Try configuring the region, i.e.
region:bg=<something> It might also be worth configuring how your
terminal emulator displays the cursor.

The last character not being highlighted (the `t' of best) is curious.
This seems to perhaps reflect the emacs mode style where you wouldn't
expect `t' to be included in the selection because the original cursor
can logically be viewed as being situated between the `s' and the `t'.

This would imply a problem with the two lines in zle_refresh.c that
read:

        } else if (invicmdmode())
            INCPOS(region_highlights[0].end);

invicmdmode() merely checks !strcmp(curkeymapname, "vicmd")

If you're able to check curkeymapname at this point in a debugger, that
might help. Note that it should be `vicmd' and not `visual' because
`visual' is only used as a local keymap. If you've got some plugin that
has replaced 'vicmd' then I'd expect that to have broken a whole lot
more of vi mode.

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author