diff options
author | James McCoy <jamessan@jamessan.com> | 2017-08-25 11:21:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 11:21:36 -0400 |
commit | 46a4099dfbc5066969f334b42bc5d92b1384db32 (patch) | |
tree | 60b63d8605647ca5ad79062a4224794b5806ea0f | |
parent | 0f2873ce99437a0267eb777201f2e98f22757c2d (diff) | |
parent | d2595ba1c4491a31d18211050e1abe86ea5379d3 (diff) | |
download | rneovim-46a4099dfbc5066969f334b42bc5d92b1384db32.tar.gz rneovim-46a4099dfbc5066969f334b42bc5d92b1384db32.tar.bz2 rneovim-46a4099dfbc5066969f334b42bc5d92b1384db32.zip |
Merge pull request #7192 from llorens/vim-8.0.0092
vim-patch:8.0.0092
-rw-r--r-- | src/nvim/indent_c.c | 33 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | test/functional/legacy/003_cindent_spec.lua | 40 |
3 files changed, 61 insertions, 14 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; } /* diff --git a/src/nvim/version.c b/src/nvim/version.c index 598c3c3778..53b44f8029 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -860,7 +860,7 @@ static const int included_patches[] = { // 95 NA // 94 NA // 93 NA - // 92, + 92, // 91, 90, // 89 NA diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua index 27835fea28..0cc4d298b7 100644 --- a/test/functional/legacy/003_cindent_spec.lua +++ b/test/functional/legacy/003_cindent_spec.lua @@ -3915,6 +3915,26 @@ describe('cindent', function() { 111111111111111111; } + namespace test::cpp17 + { + 111111111111111111; + } + namespace ::incorrectcpp17 + { + 111111111111111111; + } + namespace test::incorrectcpp17:: + { + 111111111111111111; + } + namespace test:incorrectcpp17 + { + 111111111111111111; + } + namespace test:::incorrectcpp17 + { + 111111111111111111; + } namespace{ 111111111111111111; } @@ -3986,6 +4006,26 @@ describe('cindent', function() { 111111111111111111; } + namespace test::cpp17 + { + 111111111111111111; + } + namespace ::incorrectcpp17 + { + 111111111111111111; + } + namespace test::incorrectcpp17:: + { + 111111111111111111; + } + namespace test:incorrectcpp17 + { + 111111111111111111; + } + namespace test:::incorrectcpp17 + { + 111111111111111111; + } namespace{ 111111111111111111; } |