In normal mode selection has one extra character due to the cursor position
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
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
Selection in normal mode places the cursor on the character before to the last.
Screenshots
Selection in normal mode:

Selection works fine without vim extension, and in insert mode:

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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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