Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor is one column off after leaving multi-cursor mode #3775

Open
trkoch opened this issue May 16, 2019 · 2 comments

Comments

Projects
None yet
1 participant
@trkoch
Copy link

commented May 16, 2019

Describe the bug
When in multi-cursor mode, pressing escape twice to return to normal mode leaves cursor one column to the left.

To Reproduce
Steps to reproduce the behavior:

  1. Given the text
after_action
after_action
  1. With cursor at n
after_actio>n<
after_action
  1. Enable multi-cursor mode by pressing cmd+d
  2. Leave multi-cursor mode py pressing esc, esc
  3. Cursor is at
after_acti>o<n
after_action

Expected behavior
Ideally cursor should be were it was before entering multi-cursor mode.

With regards to the example given above, I expect the cursor to be at.

after_actio>n<
after_action

Screenshots
Cursor before leaving multi-cursor mode

image

Cursor after leaving multi-cursor mode

image

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.8.0
  • VSCode version: 1.33.1
  • OS: macOS
@trkoch

This comment has been minimized.

Copy link
Author

commented May 16, 2019

I tracked down this line

vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop.getLeft()));

Removing getLeft() seems to have the desired effect (i.e. expected cursor position after leaving multi-cursor mode). However, I'm pretty sure it is there for a reason?

diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts
index 4e8da5b5..3a045ff5 100644
--- a/src/actions/commands/actions.ts
+++ b/src/actions/commands/actions.ts
@@ -543,7 +543,7 @@ class CommandEsc extends BaseCommand {
       // as that is handled for you by the state machine. ESC is
       // a special case since runsOnceForEveryCursor is false.
 
-      vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop.getLeft()));
+      vimState.cursors = vimState.cursors.map(x => x.withNewStop(x.stop));
     }
 
     if (vimState.currentMode === ModeName.SearchInProgressMode) {
@trkoch

This comment has been minimized.

Copy link
Author

commented May 17, 2019

However, I'm pretty sure it is there for a reason?

When exiting insert mode, both VSCode and Vim shift the cursor one column to the left (e.g. i, <esc>) so I'm guessing that's why it's done here as well. However, I believe this to be an error and inconsistent with visual mode. When exiting visual mode, the cursor stays at the position. Since multi-cursor mode seems to be a variation of the visual mode (as indicated in the status bar), I suggest to match its reset behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.