From 1dfe26a5385de33cd7d9a0175c4fa89defd88386 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Fri, 8 Jun 2012 16:51:28 -0400 Subject: [PATCH] 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 the pair of braces which were just separated by a could become folded, so that the trailing "o" opens a new line AFTER the pair. --- autoload/delimitMate.vim | 4 +++- test/expand_cr.txt | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim index 00ae6ed..8e0465a 100644 --- a/autoload/delimitMate.vim +++ b/autoload/delimitMate.vim @@ -418,7 +418,9 @@ function! delimitMate#ExpandReturn() "{{{ " Not sure why I used the previous combos, but I'm sure somebody will tell " me about it. - return "\a\\O" + " XXX zv prevents breaking expansion with syntax folding enabled by + " InsertLeave. + return "\a\\zvO" else return "\" endif diff --git a/test/expand_cr.txt b/test/expand_cr.txt index 331add6..190768b 100644 --- a/test/expand_cr.txt +++ b/test/expand_cr.txt @@ -46,5 +46,20 @@ sub foo { call setline(1, "\"{bracketed}") 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 {\x" +================================================================================ +abc { + x +} --------------------------------------------------------------------------------