t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Cursor position bug when switching from replace to insert mode and back #1026

Closed CyberMango closed 6 years ago

CyberMango commented 6 years ago

Atom ver: 1.23.3 VMP ver: 1.27.0 OS ver: windows 10 10.0.14393

There is a bug when in insert mode, you use the command 'activate-replace-mode', and then go to normal mode, the cursor position moves 2 chars back (instead of just 1 char). If you do repeatedly move from insert to replace mode and back using 'activate-insert/replace-mode' commands, then the cursor will move more chars back (equal to the number of times you switched)

video example: https://www.youtube.com/watch?v=-ApDhIUmvuY&feature=youtu.be

in the video i show how it acts normally when you just switch from insert/replace to normal mode, then with a single transition from insert to replace, and the cursor jumps 2 chars back. then i make multiple transitions and the cursor jumps a few chars back.

This is useful for making some keybindings and custom actions, and i dont think its a hard issue to fix (correct me if im wrong).

TY for your awesome work so far.

t9md commented 6 years ago

I confirmed behavior, ya could reproduce. But I don't want to say that behavior as BUG. As far as I understand, starting replace-mode directly from insert-mode is not allowed in pure-Vim. Replace-mode should be started from normal-mode always.

So If I work to fix this bug, I will fix by disallowing starting replace-mode from insert-mode.

CyberMango commented 6 years ago

On the vim on my Ubuntu machine, pressing the key 'Insert' while in insert mode starts Replace mode, and while in replace mode it starts insert mode (basically, it transitions between the two). Im not sure if this is a built in behavior of vim or just a configuration on my machine. i cant check this today, but i will do it tomorrow when i can.

t9md commented 6 years ago

Oh, thank you for interesting input. I didn’t know that. So, i changed my mind. Will find the way to shift mode between insert and replace directly.

t9md commented 6 years ago

Implemented and also added vim-mode-plus:toggle-replace-mode utility command.

This command works only in insert-mode to switch between insert and insert.replace mode(ya, replace mode is submode of insert, so this command of cource works in replace mode too)

'atom-text-editor.vim-mode-plus.insert-mode':
  'ctrl-cmd-r': 'vim-mode-plus:toggle-replace-mode'
t9md commented 6 years ago

will release in next version v1.28.0, maybe in a week.