Skip to content

Commit

Permalink
Fix abbreviation expansion for abbreviations with pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarWatcher committed Oct 5, 2024
1 parent 2b85d48 commit 4ee4028
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
4 changes: 2 additions & 2 deletions autoload/autopairs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -554,7 +554,7 @@ func! autopairs#AutoPairsMap(key, ...)
if l:explicit && len(maparg(key, "i")) != 0
return
endif
execute 'inoremap <buffer> <silent>' key "<C-R>=autopairs#AutoPairsInsert('" .. escaped_key .. "')<cr>"
execute 'inoremap <buffer> <silent>' key "<C-]><C-R>=autopairs#AutoPairsInsert('" .. escaped_key .. "')<cr>"
endf

func! autopairs#AutoPairsToggle()
Expand Down
33 changes: 33 additions & 0 deletions test/AbbreviationRegressionTest.vimspec
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4ee4028

Please sign in to comment.