From 9984b255c008831c91879086f7fcd70ee687d98d Mon Sep 17 00:00:00 2001 From: Kim K Date: Sun, 17 Feb 2019 15:38:37 +0100 Subject: [PATCH] feat: Also add equal-pair-detecting check when deleting pairs --- README.md | 10 ++++++++++ doc/AutoPairs.txt | 5 +++-- plugin/auto-pairs.vim | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff8642e..be64843 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,16 @@ Features --- + input: + ((|) + + (press at |) + + output: + (|) + + --- + input: |]] diff --git a/doc/AutoPairs.txt b/doc/AutoPairs.txt index 4607797..4e7d91f 100644 --- a/doc/AutoPairs.txt +++ b/doc/AutoPairs.txt @@ -281,8 +281,9 @@ Jump to the next closed pair. Default: 1 -Detects when to close a pair by detecting the equality of pairs within the -current buffer. (This feature is not supported for multibyte pairs) +Detects when to close a pair and how to delete an existing pair by detecting the +equality of pairs within the current buffer. (This feature is not supported for +multibyte pairs) *g:AutoPairsShortcutBackInsert* diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 537ca52..4d80e8a 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -342,6 +342,11 @@ func! AutoPairsDelete() return "\" end end + if strlen(open) == 1 && g:AutoPairsEqualPairDetection == 1 + if s:count(open) !=# s:count(close) + return s:backspace(b) + endif + endif return s:backspace(b).s:delete(a) end endfor