Vim: The extension does not respect vscode's selection

Environment:

  • VSCode Version: 1.12.2
  • VsCodeVim Version: 0.8.4
  • OS: Linux

What happened:

Using editor.action.smartSelect.grow to selection a string, then press c, it does not modify the whole selected text.

What did you expect to happen: The whole selected text should be modified. (Actually when I selection anything it is expected to enter visual mode. However it remains in normal mode. Even if I enter visual mode manually before executing editor.action.smartSelect.grow, the extension does not respect the selection.)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 21
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Same issue for me with Expand Selection, a workaround for me is to press v immediately after the expansion and VS Code’s selection turns into VsCodeVim’s.

Ideally, for me, VsCodeVim would respect the selection and enter visual mode automatically

I’ve been playing with our handling of selections recently. Some improvements have been made, but it’s still pretty insane. In our defense, it’s HARD, mostly because VSCode and vim have fundamentally different understandings of what constitutes a selection, and when A Thing happens to change the selections, VSCode likes to let us infer what happened based on incomplete information.

Anyway, if any brave soul does want to have some fun by poking around this stuff, let me know beforehand.

I’m looking into this. If I find anything worth developing I’ll post here.

This is correct - I tried fixing this a few weeks ago and even tried some pretty hacky workarounds but I don’t think it’s possible without introducing other, more jarring quirks

Yeah I tried forcing the vscode cursor to the right of the character but that made it flicker all over the place. I thought of using a timeout to only correct the vscode selection when the user stopped dragging but that doesn’t feel like a good idea either.

The part of keeping the pressed character selected I think it’s doable. When I did that I haven’t created the lag behind and same selection checks so I was having a few issues with it moving the anchor sometimes. But now with those logics in place it might work better. When I have some time I’ll try that and make another PR for that.

I’ve made a fix for this with PR #5015. Since this change has to be tested manually I would really appreciate someone testing that PR and giving their feedback before it gets merged.

I also found a few other things that I would like to change/fix with selections but since I didn’t want the PR to get bloated I didn’t put them there. But here are some of the things I think could be done: selections-wip

The things to note here are:

  1. When you select by click and drag the pressed character is always selected even when going back/up (notice that the character ‘M’ is always selected
  2. When you select by click and drag the character is selected as soon as you get the mouse on top of it instead of selecting after you move past the character (you can see this at the end of the gif). This is the behavior of Vim but VSCode only selects a character when you move the cursor to the right of that character which means the mouse will be on top of the next character by then. However as much as I would like to implement this I don’t think it will be possible because when doing this as you can see on the gif VSCodes selection doesn’t include the last character (you can see that when I select ‘handleKeyEvent’ the same word 4 lines below doesn’t highlight the last character). We could deal with this on the Vim side, but vscode selections would probably always be missing that last character and that visual difference on other occurrences highlight would probably annoy some people.

Note: The changes in this gif are not present on the mentioned PR. Its just some WIP I’ve been looking into.

I’ve been playing with our handling of selections recently. Some improvements have been made, but it’s still pretty insane. In our defense, it’s HARD, mostly because VSCode and vim have fundamentally different understandings of what constitutes a selection, and when A Thing happens to change the selections, VSCode likes to let us infer what happened based on incomplete information.

Anyway, if any brave soul does want to have some fun by poking around this stuff, let me know beforehand.