jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.11k stars 373 forks source link

Unexpected behaviors of backspace/delete on pairs #305

Open airglow923 opened 4 years ago

airglow923 commented 4 years ago

Say, there is the following code:

[·

]

(Note that · after [ refers to <space>)

and if I put backspace after the ·, it deletes the trailing newline.

This was once mentioned in #272 where a pair of " causing problems, but it turns out that this occurs in every possible pair (", (, {, and [).

There is another strange behavior. Consider the code below:

[<backspace>

]

If I do that, it deletes both the opening and closing brackets.

Here are the attachments that help understanding:

First case, [·<backspace>

autopairs1

Second case, [<backspace><LF><LF>]

autopairs2

airglow923 commented 4 years ago

It seems that deleting an opening pair also deletes the closing pair when there are only whitespaces between pairs, not just newline.

autopairs3