Delete the inserted blank line when close the pair
This commit is contained in:
parent
0682eb08cb
commit
3413c38fe3
@ -29,7 +29,10 @@ Features
|
|||||||
input: {|} (press <CR> at |)
|
input: {|} (press <CR> at |)
|
||||||
output: {
|
output: {
|
||||||
|
|
|
|
||||||
}
|
} (press } to close the pair)
|
||||||
|
output: {
|
||||||
|
}| (the inserted empty line will be deleted)
|
||||||
|
|
||||||
|
|
||||||
* Insert spaces before closing characters, only for [], (), {}
|
* Insert spaces before closing characters, only for [], (), {}
|
||||||
|
|
||||||
@ -388,7 +391,7 @@ TroubleShooting
|
|||||||
To fix the issue, you need remap or disable the related shortcut.
|
To fix the issue, you need remap or disable the related shortcut.
|
||||||
|
|
||||||
Known Issues
|
Known Issues
|
||||||
-----------------------
|
------------
|
||||||
Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3)
|
Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3)
|
||||||
|
|
||||||
Description: After entering insert mode and inputing `[hello` then leave insert
|
Description: After entering insert mode and inputing `[hello` then leave insert
|
||||||
|
@ -194,24 +194,21 @@ func! AutoPairsInsert(key)
|
|||||||
end
|
end
|
||||||
if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && close[0] == a:key
|
if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && close[0] == a:key
|
||||||
" the close pair is in the same line
|
" the close pair is in the same line
|
||||||
let m = matchstr(afterline, '^\v\s*\V'.close)
|
|
||||||
if m != ''
|
|
||||||
if before =~ '\V'.open.'\v\s*$' && m[0] =~ '\v\s'
|
|
||||||
" remove the space we inserted if the text in pairs is blank
|
|
||||||
return "\<DEL>".s:right(m[1:])
|
|
||||||
else
|
|
||||||
return s:right(m)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
||||||
if m != ''
|
if m != ''
|
||||||
if a:key == g:AutoPairsWildClosedPair || opt['multiline']
|
if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
|
||||||
" skip close pair greedy
|
normal! ddk$
|
||||||
call search(m, 'We')
|
elseif col('.') > 1
|
||||||
return "\<Right>"
|
normal! h
|
||||||
|
elseif line('.') > 1
|
||||||
|
normal! k$
|
||||||
else
|
else
|
||||||
|
return s:right(m)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
call search(m, 'We')
|
||||||
|
return "\<Right>"
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
endfor
|
endfor
|
||||||
@ -346,28 +343,27 @@ func! AutoPairsMoveCharacter(key)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
func! AutoPairsBackInsert()
|
func! AutoPairsBackInsert()
|
||||||
if exists('b:autopairs_saved_pair')
|
let pair = b:autopairs_saved_pair[0]
|
||||||
let pair = b:autopairs_saved_pair[0]
|
let pos = b:autopairs_saved_pair[1]
|
||||||
let pos = b:autopairs_saved_pair[1]
|
call setpos('.', pos)
|
||||||
call setpos('.', pos)
|
return pair
|
||||||
return pair
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! AutoPairsReturn()
|
func! AutoPairsReturn()
|
||||||
if b:autopairs_enabled == 0
|
if b:autopairs_enabled == 0
|
||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
" let before = getline(line('.')-1)
|
let b:autopairs_return_pos = 0
|
||||||
let [ig, ig, after] = s:getline()
|
let before = getline(line('.')-1)
|
||||||
|
let [ig, ig, afterline] = s:getline()
|
||||||
let cmd = ''
|
let cmd = ''
|
||||||
for [open, close, opt] in b:AutoPairsList
|
for [open, close, opt] in b:AutoPairsList
|
||||||
if close == ''
|
if close == ''
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
" before =~ '\V'.open.'\v\s*$' &&
|
|
||||||
if after =~ '^\s*\V'.close
|
if before =~ '\V'.open.'\v\s*$' && afterline =~ '^\s*\V'.close
|
||||||
|
let b:autopairs_return_pos = line('.')
|
||||||
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
|
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
|
||||||
" Recenter before adding new line to avoid replacing line content
|
" Recenter before adding new line to avoid replacing line content
|
||||||
let cmd = "zz"
|
let cmd = "zz"
|
||||||
@ -451,6 +447,8 @@ func! AutoPairsInit()
|
|||||||
let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter
|
let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let b:autopairs_return_pos = 0
|
||||||
|
let b:autopairs_saved_pair = [0, 0]
|
||||||
let b:AutoPairsList = []
|
let b:AutoPairsList = []
|
||||||
|
|
||||||
" buffer level map pairs keys
|
" buffer level map pairs keys
|
||||||
|
Loading…
Reference in New Issue
Block a user