On 2016-01-06, Christian Brabandt wrote:
> On Mo, 04 Jan 2016, Gary Johnson wrote:
> > I'm in the same situation.  I've been using
> > 
> >     setlocal foldmethod=marker
> >     setlocal foldmarker={,}
> > 
> > to have convenient folding of C blocks.  Every now and then the
> > folding would become corrupted by an initialization such as your
> > 
> >     static long days[13] = {30, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 
> > 31} ;
> 
> Hm, shouldn't the default value of 'foldminlines' make sure, that this 
> line is not folded?

The problem was not that that line was folded.  The problem was that
the "{30" sequence on that line was interpreted as the beginning of
a fold with level 30.  That resulted in the level of all subsequent
folds (until the next "{<integer>") being too high and the folds
being undesirably closed.

Consider the following example.  Folding is being used to close
functions in this C file.

=========================== foldlevel=99 ===========================
int x = 0;

void foo(void)
{
   x = 1;
}

void bar(void)
{
   static int a[] = {30, 60, 90};

   x = 2;
}

void baz(void)
{
   x = 3;
}
====================================================================

The following is the desired appearance after typing zM and is
achieved by the foldexpr method I posted previously.

=================== foldlevel=0 foldmethod=expr ====================
int x = 0;

void foo(void)
+-- 3 lines --------------------------------------------------------

void bar(void)
+-- 5 lines --------------------------------------------------------

void baz(void)
+-- 3 lines --------------------------------------------------------
====================================================================

The following is what happens if the foldmethod is marker and the
foldmarkers are {,}.  All the folds below the initialization of a[]
are closed because the }'s at the ends of the initialization and of
bar() don't lower the fold level enough for the text to be unfolded.

================== foldlevel=0 foldmethod=marker ===================
int x = 0;

void foo(void)
+-- 3 lines --------------------------------------------------------

void bar(void)
+-- 10 lines -------------------------------------------------------
====================================================================

Even after raising the foldlevel to 3, all the folds below the
initialization of a[] are still closed.

================== foldlevel=3 foldmethod=marker ===================
int x = 0;

void foo(void)
{
   x = 1;
}

void bar(void)
{
   +----- 9 lines --------------------------------------------------
====================================================================

I understand why all of the above occur.  They just illustrate that
using foldmarker={,} without being able to disable the marker
fold level tag is not satisfactory for folding C blocks.

Regards,
Gary

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui