vim-jp/vim-cpp

Folding in cpp files by syntax is broken.

madevgeny opened this issue · 5 comments

On start vim folds all code starting from the first function into one big fold and only then fold functions right.

I found that problem is in the following code in c.vim starting from 138 line:

if &filetype ==# 'cpp' && !exists("cpp_no_cpp11")
  syntax region cBadBlock       start="{" end="}" transparent fold
else
  syntax region cBadBlock   keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold
endif

if replace 
syntax region   cBadBlock       start="{" end="}" transparent fold
with 
syntax region   cBadBlock       start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold

folding works well.

Please show me the code that you want folding.

fold
Here it is code:

static State state;

static bool ping(void *arg)
{
    State &s = *(State*)arg;
    // connect to device
    s.proccess();
    return true;
}

bool worker_init()
{
    if(!core::Timer::instance().init()){
        return false;
    }

    state.readConfig(CONFIG_FILE);

    core::Timer::instance().add(TIME_INTERVAL, ping, &state);

    return true;
}

void worker_deinit()
{
    core::Timer::instance().deinit();
}

void worker_reload()
{
    state.readConfig(CONFIG_FILE);
}

It's my vim folding settings"

set foldmethod=syntax
set foldignore=#,//
set foldcolumn=2
set shiftwidth=4
set foldlevel=0
set foldminlines=3

Hmm, I got below

BTW, we updated cpp.vim yesterday. So please update this and try again.

After update issue disappeared. Thank you very much.