diff options
author | Lech Lorens <lech.lorens@gmail.com> | 2017-08-20 12:14:27 +0200 |
---|---|---|
committer | Lech Lorens <lech.lorens@gmail.com> | 2017-08-21 23:00:51 +0200 |
commit | d2595ba1c4491a31d18211050e1abe86ea5379d3 (patch) | |
tree | 8d7248d001c3cbbc94c12aaeca044659262fdbe9 /src/nvim/indent_c.c | |
parent | b3da396804ec0a63f11b86a363bd4c98e23f8ebd (diff) | |
download | rneovim-d2595ba1c4491a31d18211050e1abe86ea5379d3.tar.gz rneovim-d2595ba1c4491a31d18211050e1abe86ea5379d3.tar.bz2 rneovim-d2595ba1c4491a31d18211050e1abe86ea5379d3.zip |
vim-patch:8.0.0092
Problem: C indenting does not support nested namespaces that C++ 17 has.
Solution: Add check that passes double colon inside a name. (Pauli, closes
vim/vim#1214)
https://github.com/vim/vim/commit/ca8b8d6956dd881de6446fc32c38e817a364a6cc
Diffstat (limited to 'src/nvim/indent_c.c')
-rw-r--r-- | src/nvim/indent_c.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index fd194a4080..4a6393ac36 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -515,34 +515,41 @@ int cin_isscopedecl(char_u *s) /* Maximum number of lines to search back for a "namespace" line. */ #define FIND_NAMESPACE_LIM 20 -/* - * Recognize a "namespace" scope declaration. - */ -static int cin_is_cpp_namespace(char_u *s) +// Recognize a "namespace" scope declaration. +static bool cin_is_cpp_namespace(char_u *s) { - char_u *p; - int has_name = FALSE; + char_u *p; + bool has_name = false; + bool has_name_start = false; s = cin_skipcomment(s); if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) { p = cin_skipcomment(skipwhite(s + 9)); while (*p != NUL) { if (ascii_iswhite(*p)) { - has_name = TRUE; /* found end of a name */ + has_name = true; // found end of a name p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') { break; } else if (vim_iswordc(*p)) { - if (has_name) - return FALSE; /* word character after skipping past name */ - ++p; + has_name_start = true; + if (has_name) { + return false; // word character after skipping past name + } + p++; + } else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2])) { + if (!has_name_start || has_name) { + return false; + } + // C++ 17 nested namespace + p += 3; } else { - return FALSE; + return false; } } - return TRUE; + return true; } - return FALSE; + return false; } /* |