Vim: Selection highlight display inconsistent

Expect: Display selection highlight for meta-d and Mouse Selection the same as Double Click.

The weird thing disturbed me is the last character is not highlighting, but it will be copied when I do y or Ctrl-c.

Btw, doing vaw on a word without special character at the end of a line may select \n and some spaces of next line.

  • VSCode Version: 1.10.2
  • VsCodeVim Version: 0.6.11
  • OS: OS X EI Capitan 10.11.6

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Copied from https://github.com/VSCodeVim/Vim/issues/1711 @sebastjaeger

Environment:

  • VSCode Version: 1.12.2
  • VsCodeVim Version: 0.7.1
  • OS: MacOS 10.12.4 / Ubuntu 15.04

What happened:

There are multiple surprising effects when selecting e.g. a word in visual mode

  • the last character is not highlighted like the rest of the selection
  • when copying the word using y the entire word is copied and can be retrieved with p (as expected)
  • the last character is lost when pasting the word via the selection clipboard (* buffer in vim, mouse middle click in linux)
  • vscode highlights not only all the other occurrences of the selected word, but everything that matches all but the last letter of the selection

What did you expect to happen:

Clearly show that the last character of the selection belongs to the selection. Make sure the last character is copied into the selection clipboard. Highlight other occurrences of the selection correctly.

Thanks for the write up @unnamedcrewman. I think that provides very clear motivation to fix our dumb selection bug once and for all.

I think the biggest problem here is the difference between Vim and VScode selections. In VSCode Vim, if you are yanking with “y”, the letter under the cursor is included. However, anything that relies on what vanilla VSCode considers a text selection will not actually include the letter under the cursor if the selection is made in visual mode in the same way as one does for yanking.

For what it’s worth, this means that:

  1. The user has to remember that any selections in normal/visual (block cursor) mode look different depending on whether you are “yanking” (includes the letter under the cursor) or “copying” with ctrl-c or the Windows menu options (does not include the letter under the cursor). I suspect the average user in a Windows environment would assume yanking and copying to be the same thing. Probably many Vim users actually consider them pretty much as synonyms.

  2. Certain extensions might give unexpected results. A user might be used to making a selection for “yanking” in visual/normal mode by ending with the cursor directly on the last character of the selection. But for an extension that manipulates text selections, the user has to remember to make sure that for any normal/visual mode selection the cursor must be placed one character past the end of the intended selection material to get the expected output.

Obviously, neither of these scenarios is a huge deal, but the second one could introduce problems that are not immediately obvious in casual reading of the output text (dropped punctuation, newlines, etc.).

Was the last letter issue fixed? When I select with mouse from the right, it does not copy the last letter for me:

vim_selection

Vscodevim version: v1.21.3 on Mac. Thanks!

Double clicking a word displayed in the right place and it interacted correctly. The main issue is the highlighting selection region of mouse selection. Just as the follows image:

image

I don’t know whether the last character ‘m’ is selected (Actually it is selected, but the highlighting of the references in other places of this document are wrong).

And doing double click it display as follows:

image

I think the later display is better.

it’s still not fixed in v0.7.1.