vim-autoclose icon indicating copy to clipboard operation
vim-autoclose copied to clipboard

Backspace in Insert mode sometimes moves the cursor back one before deleting

Open roryokane opened this issue 7 years ago • 0 comments

Bug description

When a document is set up like this, with a two-letter word started and the cursor in the first line of a wrapped line (with :set wrap):

▌foo foo foo foo re▐
▌|                 ▐
Legend
  • = left margin of window
  • = right margin of window
  • | = cursor in Insert mode

Sometimes, pressing Backspace will delete the second-to-last character r and place the cursor where it had been:

▌foo foo foo foo |e▐

instead of deleting the last character e and being in this desired state:

▌foo foo foo foo r|▐

I kept running into this bug while typing up two-sentence log entries and sometimes using Backspace to delete words I wanted to retype.

A test case to reproduce the bug with

One of my files to reproduce the bug in contained this:

Test cases, for an 80-character-wide window:

Go to the end of this line, append “ 12”, and press Backspace. The bug is reproduced.

wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww 12

Go to the end of this line, delete a character, append “w 12”, and press Backspace. The bug is reproduced.

wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

I couldn’t always reproduce the bug with this, though. If I did other edits to the file, undid them, and then followed the reproduction steps, sometimes the bug wouldn’t trigger.

Cause of the bug

The cause of the bug is the inoremap <BS> mapping defined within plugin/AutoClose.vim. When I run :imap <BS>, I can see that that is the only mapping that would trigger.

Workaround

My workaround was uninstalling AutoClose and switching to delimitMate.

roryokane avatar Feb 24 '18 06:02 roryokane