mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Fix CR expansion & syn fold enabled by InsertLeave
Benamin Fritz reported the following: Without the "zv", if the user has syntax folding on, when the mapping invokes <Esc> the pair of braces which were just separated by a <CR> could become folded, so that the trailing "o" opens a new line AFTER the pair.
This commit is contained in:
@@ -418,7 +418,9 @@ function! delimitMate#ExpandReturn() "{{{
|
|||||||
|
|
||||||
" Not sure why I used the previous combos, but I'm sure somebody will tell
|
" Not sure why I used the previous combos, but I'm sure somebody will tell
|
||||||
" me about it.
|
" me about it.
|
||||||
return "\<Esc>a\<CR>\<Esc>O"
|
" XXX zv prevents breaking expansion with syntax folding enabled by
|
||||||
|
" InsertLeave.
|
||||||
|
return "\<Esc>a\<CR>\<Esc>zvO"
|
||||||
else
|
else
|
||||||
return "\<CR>"
|
return "\<CR>"
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -46,5 +46,20 @@ sub foo {
|
|||||||
call setline(1, "\"{bracketed}")
|
call setline(1, "\"{bracketed}")
|
||||||
normal A"x
|
normal A"x
|
||||||
================================================================================
|
================================================================================
|
||||||
"{bracketed}"x
|
"{bracketed""x
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
||||||
|
# with :normal
|
||||||
|
new
|
||||||
|
autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
|
||||||
|
autocmd InsertLeave * let &foldmethod = w:fdm
|
||||||
|
set foldmethod=marker
|
||||||
|
set foldmarker={,}
|
||||||
|
set foldlevel=0
|
||||||
|
set backspace=2
|
||||||
|
exec "normal iabc {\<CR>x"
|
||||||
|
================================================================================
|
||||||
|
abc {
|
||||||
|
x
|
||||||
|
}
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user