From 4ee4028b9078e8478b0f7ba2091b6e86759fd54e Mon Sep 17 00:00:00 2001 From: Olivia Date: Sun, 6 Oct 2024 01:09:19 +0200 Subject: [PATCH] Fix abbreviation expansion for abbreviations with pairs #93 --- CHANGELOG.md | 6 +++++ autoload/autopairs.vim | 4 +-- test/AbbreviationRegressionTest.vimspec | 33 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/AbbreviationRegressionTest.vimspec diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f8c0f..38562d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [Unreleased] +`g:AutoPairsVersion = 40004` + +## Fixed +* Abbreviations with pairs ([#93](https://github.com/LunarWatcher/auto-pairs/issues/93)) + # 4.1.0 `g:AutoPairsVersion = 40003` diff --git a/autoload/autopairs.vim b/autoload/autopairs.vim index ae4210a..7a2c7fd 100644 --- a/autoload/autopairs.vim +++ b/autoload/autopairs.vim @@ -18,7 +18,7 @@ endif " meant as a number associated with the version. Semantic meaning on the first " digit will take place. See the documentation for more details. -let g:AutoPairsVersion = 40003 +let g:AutoPairsVersion = 40004 let s:save_cpo = &cpoptions set cpoptions&vim @@ -554,7 +554,7 @@ func! autopairs#AutoPairsMap(key, ...) if l:explicit && len(maparg(key, "i")) != 0 return endif - execute 'inoremap ' key "=autopairs#AutoPairsInsert('" .. escaped_key .. "')" + execute 'inoremap ' key "=autopairs#AutoPairsInsert('" .. escaped_key .. "')" endf func! autopairs#AutoPairsToggle() diff --git a/test/AbbreviationRegressionTest.vimspec b/test/AbbreviationRegressionTest.vimspec new file mode 100644 index 0000000..bec0ecd --- /dev/null +++ b/test/AbbreviationRegressionTest.vimspec @@ -0,0 +1,33 @@ +Describe Abbreviations should work with weird stuff + Before each + call autopairs#Variables#InitVariables() + End + After each + abclear + End + It should work with pairs at the start [#93] + new | only! + abbr (a Test + + call Expect("(a").ToMatch("Test)") + call Expect("(a ").ToMatch("Test )") + End + It should work with pairs at the end [#93] + new | only! + abbr a( Test + + " I don't understand why the previous test doesn't need a trigger, + " but this one does. Really weird and inconsistent behaviour, + " and I wasn't able to reproduce this with my config (and I don't use + " abbreviations, so all that shit should be default) + call Expect("a( ").ToMatch("Test )") + End + It should work with balanced pairs in the middle [#93] + new | only! + " Not sure why these need to be balanced to keep abbr from throwing an + " E474 + abbr a(b) Test + + call Expect("a(b) ").ToMatch("Test ") + End +End