Skip to content

Commit 4ee4028

Browse files
committed
Fix abbreviation expansion for abbreviations with pairs
#93
1 parent 2b85d48 commit 4ee4028

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# [Unreleased]
2+
`g:AutoPairsVersion = 40004`
3+
4+
## Fixed
5+
* Abbreviations with pairs ([#93](https://github.com/LunarWatcher/auto-pairs/issues/93))
6+
17
# 4.1.0
28
`g:AutoPairsVersion = 40003`
39

autoload/autopairs.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif
1818
" meant as a number associated with the version. Semantic meaning on the first
1919
" digit will take place. See the documentation for more details.
2020

21-
let g:AutoPairsVersion = 40003
21+
let g:AutoPairsVersion = 40004
2222

2323
let s:save_cpo = &cpoptions
2424
set cpoptions&vim
@@ -554,7 +554,7 @@ func! autopairs#AutoPairsMap(key, ...)
554554
if l:explicit && len(maparg(key, "i")) != 0
555555
return
556556
endif
557-
execute 'inoremap <buffer> <silent>' key "<C-R>=autopairs#AutoPairsInsert('" .. escaped_key .. "')<cr>"
557+
execute 'inoremap <buffer> <silent>' key "<C-]><C-R>=autopairs#AutoPairsInsert('" .. escaped_key .. "')<cr>"
558558
endf
559559

560560
func! autopairs#AutoPairsToggle()
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Describe Abbreviations should work with weird stuff
2+
Before each
3+
call autopairs#Variables#InitVariables()
4+
End
5+
After each
6+
abclear
7+
End
8+
It should work with pairs at the start [#93]
9+
new | only!
10+
abbr (a Test
11+
12+
call Expect("(a").ToMatch("Test)")
13+
call Expect("(a ").ToMatch("Test )")
14+
End
15+
It should work with pairs at the end [#93]
16+
new | only!
17+
abbr a( Test
18+
19+
" I don't understand why the previous test doesn't need a trigger,
20+
" but this one does. Really weird and inconsistent behaviour,
21+
" and I wasn't able to reproduce this with my config (and I don't use
22+
" abbreviations, so all that shit should be default)
23+
call Expect("a( ").ToMatch("Test )")
24+
End
25+
It should work with balanced pairs in the middle [#93]
26+
new | only!
27+
" Not sure why these need to be balanced to keep abbr from throwing an
28+
" E474
29+
abbr a(b) Test
30+
31+
call Expect("a(b) ").ToMatch("Test ")
32+
End
33+
End

0 commit comments

Comments
 (0)