Skip to content

Commit

Permalink
Merge pull request #2069 from yTakatsukasa/fix1538
Browse files Browse the repository at this point in the history
Fix #1538 (local disabling is ignored).
  • Loading branch information
hzeller authored Dec 27, 2023
2 parents 9cb4509 + 221c78d commit a962c2d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
12 changes: 5 additions & 7 deletions common/formatting/unwrapped_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,11 @@ std::ostream &FormattedExcerpt::FormattedText(
const auto &front = tokens_.front();
if (include_token_p(*front.token)) {
VLOG(2) << "action: " << front.before.action;
switch (front.before.action) {
case SpacingDecision::kAlign:
// When aligning tokens, the first token might be further indented.
stream << Spacer(front.before.spaces) << front.token->text();
break;
default:
stream << front.token->text();
if (indent && front.before.action == SpacingDecision::kAlign) {
// When aligning tokens, the first token might be further indented.
stream << Spacer(front.before.spaces) << front.token->text();
} else {
stream << front.token->text();
}
}
for (const auto &ftoken :
Expand Down
22 changes: 22 additions & 0 deletions verilog/formatting/formatter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15465,6 +15465,28 @@ static constexpr FormatterTestCase kFormatterTestCases[] = {
"end\n",
"always @( /*t*/ * /*t*/) begin\n"
"end\n"},
{
// Don't touch verilog_format:off region #1538
R"(
module testcode;
// verilog_format: off
assign a = b
& c;
// verilog_format: on
assign e = d;
endmodule
)",
R"(
module testcode;
// verilog_format: off
assign a = b
& c;
// verilog_format: on
assign e = d;
endmodule
)",

},

// -----------------------------------------------------------------
};
Expand Down

0 comments on commit a962c2d

Please sign in to comment.