VSCodeVim / VSCodeVim/Vim

In normal mode selection has one extra character due to the cursor position

Open
#3,661 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
When setting a selection programatically n an editor in normal mode the cursor is incorrectly positioned, which causes problems for other commands (e.g. copy).

To Reproduce
Change an editor selection programatically while in normal mode:

editor.selection = new vscode.Selection(
        start.line,
        start.character,
        end.line,
        end.character
);

See that the cursor is at the last character

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Selection in normal mode places the cursor on the character before to the last.

Screenshots
Selection in normal mode:
Screen Shot 2019-04-07 at 2 39 46 PM

Selection works fine without vim extension, and in insert mode:
Screen Shot 2019-04-07 at 2 40 36 PM

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.3.0
  • VSCode version: 1.3.3
  • OS: Mojave 10.14.3

Additional context
I encountered this when writing my own plugin: https://github.com/germtb/vscode-token-navigation

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the programmatic editor.selection assignment shown in the report, comparing normal mode with insert mode. Trace the extension's normal-mode selection handling; done means the cursor is before the final character and commands such as copy operate on the intended selection. No file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.