VimFold4C icon indicating copy to clipboard operation
VimFold4C copied to clipboard

Folds for c++11 range-based for loops and c++11 list initialization

Open kiryph opened this issue 7 years ago • 1 comments

Following example source code

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> v = {0, 1, 2, 3, 4, 5};
 
    for (const int& i : v)
    {
        std::cout << i << ' ';
    }

    for (auto& c : google::GetLoggingDirectories()) {
        std::clog << c << "\n";
    }
}

has following folds screen shot 2018-02-06 at 14 35 50 and folds to screen shot 2018-02-06 at 14 36 19

My issues are

  • I would not expect that a single line will be folded (line 6). With the following blank line the fold is actually two lines long. I know that :set foldminlines=3 removes this fold.
  • The fold text for range-based folds and the initialization list is trimmed more than necessary.

The values of g:fold_options in my vimrc are

let g:fold_options = {
   \ 'show_if_and_else': 1,
   \ 'strip_template_argurments': 1,
   \ 'strip_namespaces': 1,
   \ 'fold_blank': 0,
   \ 'max_foldline_length': 'tw',
   \ }

kiryph avatar Feb 06 '18 13:02 kiryph

The single line is actually not that single. It's merged with the next line which is empty. In order to ignore such cases, I should take fold_blank into account, which I don't.

Regarding the trimming of for range-loops, there was bug that should be fixed now -- the range was discarded. Still, I avoid to make to distinctions between the kind of lines before trimming them. I could of course ignore loops and such, but that'll mean another option.

LucHermitte avatar Feb 06 '18 14:02 LucHermitte