From 33ecfd759d32bc8835a6d76a8e24e17ecf5c56f8 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Sat, 29 Oct 2016 11:46:39 -0700 Subject: [PATCH] Recenter before adding line, fix overwriting copy --- plugin/auto-pairs.vim | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 200b2dd..0a263cb 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -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 \ instead of \cl will cause the placeholder deleted - " incorrect. because zz won't leave Normal mode. - " Use \ 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 = "\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 "\O".cmd + return "\".cmd."O" endif " conflict with javascript and coffee " javascript need indent new line " coffeescript forbid indent new line if &filetype == 'coffeescript' || &filetype == 'coffee' - return "\k==o".cmd + return "\".cmd."k==o" else - return "\=ko".cmd + return "\".cmd."=ko" endif end return ''