Skip to content

Commit

Permalink
Recenter before adding line, fix overwriting copy
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek committed Oct 29, 2016
1 parent 63b0c1b commit 33ecfd7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugin/auto-pairs.vim
Expand Up @@ -380,27 +380,23 @@ function! AutoPairsReturn()
let cur_char = line[col('.')-1]
if has_key(b:AutoPairs, prev_char) && b:AutoPairs[prev_char] == cur_char
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
" Use \<BS> instead of \<ESC>cl will cause the placeholder deleted
" incorrect. because <C-O>zz won't leave Normal mode.
" Use \<DEL> is a bit wierd. the character before cursor need to be deleted.
" Adding a space, recentering, and deleting it interferes with default
" whitespace-removing behavior when exiting insert mode.
let cmd = "\<ESC>zzcc"
" Recenter before adding new line to avoid replacing line content
let cmd = "zz"
end

" If equalprg has been set, then avoid call =
" https://github.com/jiangmiao/auto-pairs/issues/24
if &equalprg != ''
return "\<ESC>O".cmd
return "\<ESC>".cmd."O"
endif

" conflict with javascript and coffee
" javascript need indent new line
" coffeescript forbid indent new line
if &filetype == 'coffeescript' || &filetype == 'coffee'
return "\<ESC>k==o".cmd
return "\<ESC>".cmd."k==o"
else
return "\<ESC>=ko".cmd
return "\<ESC>".cmd."=ko"
endif
end
return ''
Expand Down

0 comments on commit 33ecfd7

Please sign in to comment.