diff --git a/src/indent.cpp b/src/indent.cpp index a7f1189e24..4428154b8a 100644 --- a/src/indent.cpp +++ b/src/indent.cpp @@ -2830,7 +2830,6 @@ void indent_text() && frm.at(sub).pc->IsOnSameLine(frm.top().pc)) { sub--; - skipped = true; } if ( ( frm.at(sub + 1).type == CT_CLASS_COLON @@ -2844,7 +2843,6 @@ void indent_text() log_indent(); frm.top().indent_tab = frm.top().indent; - skipped = true; } else { @@ -2918,7 +2916,9 @@ void indent_text() } log_indent(); - if ( pc->level == pc->brace_level + if ( ( pc->level == pc->brace_level // Issue #3752 + || ( pc->level > pc->brace_level + && !language_is_set(LANG_OC))) && !options::indent_ignore_first_continue() && ( pc->Is(CT_FPAREN_OPEN) || pc->Is(CT_SPAREN_OPEN) diff --git a/tests/config/cpp/Issue_3428.cfg b/tests/config/cpp/Issue_3428.cfg index d87966825d..ef786f436d 100644 --- a/tests/config/cpp/Issue_3428.cfg +++ b/tests/config/cpp/Issue_3428.cfg @@ -5,3 +5,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3428_2.cfg b/tests/config/cpp/Issue_3428_2.cfg index 26e8a8ed2f..ba907f030d 100644 --- a/tests/config/cpp/Issue_3428_2.cfg +++ b/tests/config/cpp/Issue_3428_2.cfg @@ -6,3 +6,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3428_3.cfg b/tests/config/cpp/Issue_3428_3.cfg index b61cf6b5ac..531a6a29a1 100644 --- a/tests/config/cpp/Issue_3428_3.cfg +++ b/tests/config/cpp/Issue_3428_3.cfg @@ -7,3 +7,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3428_4.cfg b/tests/config/cpp/Issue_3428_4.cfg index e0f3a86525..9194262e3d 100644 --- a/tests/config/cpp/Issue_3428_4.cfg +++ b/tests/config/cpp/Issue_3428_4.cfg @@ -5,3 +5,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3428_5.cfg b/tests/config/cpp/Issue_3428_5.cfg index 1d4c1f30e4..913277bebd 100644 --- a/tests/config/cpp/Issue_3428_5.cfg +++ b/tests/config/cpp/Issue_3428_5.cfg @@ -6,3 +6,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3428_6.cfg b/tests/config/cpp/Issue_3428_6.cfg index 6b13943551..a52618c6ce 100644 --- a/tests/config/cpp/Issue_3428_6.cfg +++ b/tests/config/cpp/Issue_3428_6.cfg @@ -7,3 +7,4 @@ indent_columns = 4 indent_with_tabs = 0 indent_continue = 4 indent_paren_close = 2 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/Issue_3752.cfg b/tests/config/cpp/Issue_3752.cfg new file mode 100644 index 0000000000..ffe0421faf --- /dev/null +++ b/tests/config/cpp/Issue_3752.cfg @@ -0,0 +1,8 @@ +input_tab_size = 4 +output_tab_size = 4 +indent_columns = 4 +indent_with_tabs = 0 + +indent_ignore_first_continue = false +indent_continue = 4 + diff --git a/tests/config/cpp/indent_continue-0.cfg b/tests/config/cpp/indent_continue-0.cfg new file mode 100644 index 0000000000..41ed668f16 --- /dev/null +++ b/tests/config/cpp/indent_continue-0.cfg @@ -0,0 +1,3 @@ +indent_with_tabs = 0 +indent_columns = 2 +indent_continue = 0 diff --git a/tests/config/cpp/indent_continue-4.cfg b/tests/config/cpp/indent_continue-4.cfg new file mode 100644 index 0000000000..3916f37b76 --- /dev/null +++ b/tests/config/cpp/indent_continue-4.cfg @@ -0,0 +1,4 @@ +indent_with_tabs = 0 +indent_columns = 2 +indent_continue = 4 +use_indent_continue_only_once = true diff --git a/tests/config/cpp/indent_continue-neg-4.cfg b/tests/config/cpp/indent_continue-neg-4.cfg new file mode 100644 index 0000000000..c21e4929f4 --- /dev/null +++ b/tests/config/cpp/indent_continue-neg-4.cfg @@ -0,0 +1,3 @@ +indent_with_tabs = 0 +indent_columns = 2 +indent_continue = -4 diff --git a/tests/cpp.test b/tests/cpp.test index d905bb7fca..c0a26bd2d2 100644 --- a/tests/cpp.test +++ b/tests/cpp.test @@ -1125,3 +1125,8 @@ 60086 cpp/indent_namespace_inner_only.cfg cpp/indent_namespace_inner_only.h 60087 cpp/Issue_3550.cfg cpp/Issue_3550.cpp 60088 common/empty.cfg cpp/Issue_3761.cpp +60089 cpp/Issue_3752.cfg cpp/Issue_3752.cpp + +60100 cpp/indent_continue-0.cfg cpp/indent_continue.cpp +60101 cpp/indent_continue-4.cfg cpp/indent_continue.cpp +60102 cpp/indent_continue-neg-4.cfg cpp/indent_continue.cpp diff --git a/tests/expected/cpp/30818-bug_1169.cpp b/tests/expected/cpp/30818-bug_1169.cpp index b1138a57a3..fad4dc1eb3 100644 --- a/tests/expected/cpp/30818-bug_1169.cpp +++ b/tests/expected/cpp/30818-bug_1169.cpp @@ -4,21 +4,21 @@ class MyClass virtual void f1ooooooooooooooo(const int bar); virtual void f2oooooooooooooooo(const int bar); virtual void f3ooooooooooooooooo( - const int bar); + const int bar); virtual void f4oooooooooooooooooo( - const int bar); + const int bar); virtual void f5ooooooooooooooooooo( - const int bar); + const int bar); }; virtual void f1oooooooooooooooooo(const int bar); virtual void f2ooooooooooooooooooo(const int bar); virtual void f3oooooooooooooooooooo( - const int bar); + const int bar); virtual void f4ooooooooooooooooooooo( - const int bar); + const int bar); virtual void f5oooooooooooooooooooooo( - const int bar); + const int bar); void foo() { diff --git a/tests/expected/cpp/31593-sf593.cpp b/tests/expected/cpp/31593-sf593.cpp index 2d4499e650..ea27c496c2 100644 --- a/tests/expected/cpp/31593-sf593.cpp +++ b/tests/expected/cpp/31593-sf593.cpp @@ -3,7 +3,7 @@ int main() { int argument = 1; sp_RatherLongClassName_t ratherLongVariableName1(new RatherLongClassName(argument, - argument, argument)); + argument, argument)); int the_result = a_very_long_function_name_taking_most_of_the_line(argument, argument, argument); diff --git a/tests/expected/cpp/60055-issue_3116.cpp b/tests/expected/cpp/60055-issue_3116.cpp index fcc3841543..a5aeb8929f 100644 --- a/tests/expected/cpp/60055-issue_3116.cpp +++ b/tests/expected/cpp/60055-issue_3116.cpp @@ -112,9 +112,9 @@ Func([] { A( B([] (const std::string &s) -> bool { - s = "hello"; - return true; - }), 1 + s = "hello"; + return true; + }), 1 ); A( @@ -149,24 +149,24 @@ A( } Func(std::count_if(v.begin(), v.end(), [&](const auto &a) { - return a == 3; - })); + return a == 3; + })); Func( std::count_if(v.begin(), v.end(), [&](const auto &a) - { - return a == 3; - })); + { + return a == 3; + })); Func( std::count_if(v.begin(), v.end(), [&](const auto &a) { - return a == 3; - })); + return a == 3; + })); Func( std::count_if(v.begin(), v.end(), [&](const auto &a) { - return a == 3; - }) + return a == 3; + }) ); // Test case from issue #3116 @@ -227,7 +227,7 @@ obj->Func([] obj->Func( Func([] - { - return b; - }) + { + return b; + }) ); diff --git a/tests/expected/cpp/60056-issue_3116-2.cpp b/tests/expected/cpp/60056-issue_3116-2.cpp index 0ce3875616..dc4dd36eec 100644 --- a/tests/expected/cpp/60056-issue_3116-2.cpp +++ b/tests/expected/cpp/60056-issue_3116-2.cpp @@ -1,9 +1,9 @@ obj.AddObject(Object::UniqueName(), 10, [this] { holder.Access([this](const auto &info) { - if (IsGood(info)) { - Add(info); - } - }); + if (IsGood(info)) { + Add(info); + } + }); }); obj.AddObject( @@ -11,20 +11,20 @@ obj.AddObject( 10, [this] { holder.Access([this](const auto &info) { - if (IsGood(info)) { - Add(info); - } - }); + if (IsGood(info)) { + Add(info); + } + }); } ); { obj.AddObject(Object::UniqueName(), 10, [this] { holder.Access([this](const auto &info) { - if (IsGood(info)) { - Add(info); - } - }); + if (IsGood(info)) { + Add(info); + } + }); }); obj.AddObject( @@ -32,10 +32,10 @@ obj.AddObject( 10, [this] { holder.Access([this](const auto &info) { - if (IsGood(info)) { - Add(info); - } - }); + if (IsGood(info)) { + Add(info); + } + }); } ); } diff --git a/tests/expected/cpp/60089-Issue_3752.cpp b/tests/expected/cpp/60089-Issue_3752.cpp new file mode 100644 index 0000000000..9174bd8afa --- /dev/null +++ b/tests/expected/cpp/60089-Issue_3752.cpp @@ -0,0 +1,59 @@ +foo( + 1 + ); + +foo(bar( + 1 + ) + ); + +foo(bar(baz( + 1) + ) + ); + +foo(bar( + baz( + 1) + ) + ); + +foo( + bar(baz( + 1) + ) + ); + +foo( + bar( + baz( + 1) + ) + ); + +foo( + 1, + bar( + 2, + baz( + 3 + ) + ) + ); + +foo(1, + bar(2, + 3 + ) + ); + +namespace ns +{ +foo(1 + , 2 + , [](a, b) { + bar(3 + , 4 + ); + }); +} diff --git a/tests/expected/cpp/60100-indent_continue.cpp b/tests/expected/cpp/60100-indent_continue.cpp new file mode 100644 index 0000000000..304867d90b --- /dev/null +++ b/tests/expected/cpp/60100-indent_continue.cpp @@ -0,0 +1,43 @@ +fn(p1, + p2 + ); + +fn( + p1, + p2 + ); + +x = fn(p1, + p2 + ); + +x = fn( + p1, + p2 + ); + +while (x && + y + ) +{ +} + +while ( + x && y + ) +{ +} + +fn(jk( + p1, + p2 + ) + ); + +fn( + jk( + p1, + p2 + ) + ); + diff --git a/tests/expected/cpp/60101-indent_continue.cpp b/tests/expected/cpp/60101-indent_continue.cpp new file mode 100644 index 0000000000..ed9c644a4a --- /dev/null +++ b/tests/expected/cpp/60101-indent_continue.cpp @@ -0,0 +1,43 @@ +fn(p1, + p2 + ); + +fn( + p1, + p2 + ); + +x = fn(p1, + p2 + ); + +x = fn( + p1, + p2 + ); + +while (x && + y + ) +{ +} + +while ( + x && y + ) +{ +} + +fn(jk( + p1, + p2 + ) + ); + +fn( + jk( + p1, + p2 + ) + ); + diff --git a/tests/expected/cpp/60102-indent_continue.cpp b/tests/expected/cpp/60102-indent_continue.cpp new file mode 100644 index 0000000000..7755c9f068 --- /dev/null +++ b/tests/expected/cpp/60102-indent_continue.cpp @@ -0,0 +1,43 @@ +fn(p1, + p2 + ); + +fn( + p1, + p2 + ); + +x = fn(p1, + p2 + ); + +x = fn( + p1, + p2 + ); + +while (x && + y + ) +{ +} + +while ( + x && y + ) +{ +} + +fn(jk( + p1, + p2 + ) + ); + +fn( + jk( + p1, + p2 + ) + ); + diff --git a/tests/input/cpp/Issue_3752.cpp b/tests/input/cpp/Issue_3752.cpp new file mode 100644 index 0000000000..84aba724f2 --- /dev/null +++ b/tests/input/cpp/Issue_3752.cpp @@ -0,0 +1,59 @@ +foo( +1 +); + +foo(bar( +1 +) +); + +foo(bar(baz( +1) +) +); + +foo(bar( +baz( +1) +) +); + +foo( +bar(baz( +1) +) +); + +foo( +bar( +baz( +1) +) +); + +foo( +1, +bar( +2, +baz( +3 +) +) +); + +foo(1, +bar(2, +3 +) +); + +namespace ns +{ +foo(1 +, 2 +, [](a, b) { +bar(3 +, 4 +); +}); +} diff --git a/tests/input/cpp/indent_continue.cpp b/tests/input/cpp/indent_continue.cpp new file mode 100644 index 0000000000..9d0698ecca --- /dev/null +++ b/tests/input/cpp/indent_continue.cpp @@ -0,0 +1,43 @@ +fn(p1, +p2 +); + +fn( +p1, +p2 +); + +x = fn(p1, +p2 +); + +x = fn( +p1, +p2 +); + +while (x && +y +) +{ +} + +while ( +x && y +) +{ +} + +fn(jk( +p1, +p2 +) +); + +fn( +jk( +p1, +p2 +) +); +