Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/lib/Format/DefinitionBlockSeparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ void DefinitionBlockSeparator::separateBlocks(
const auto MayPrecedeDefinition = [&](const int Direction = -1) {
assert(Direction >= -1);
assert(Direction <= 1);

if (Style.isCSharp() &&
Lines[OpeningLineIndex]->First->is(TT_CSharpGenericTypeConstraint)) {
return true;
}

const size_t OperateIndex = OpeningLineIndex + Direction;
assert(OperateIndex < Lines.size());
const auto &OperateLine = Lines[OperateIndex];
Expand Down
5 changes: 5 additions & 0 deletions clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ TEST_F(DefinitionBlockSeparatorTest, CSharp) {
"\r\n"
"public class FoobarClass {\r\n"
" int foobar;\r\n"
"}\r\n"
"\r\n"
"public class LogFactory<TLogger>\r\n"
" where TLogger : class, new() {\r\n"
" int i;\r\n"
"}",
Style);
}
Expand Down