Copilot commented on code in PR #12956:
URL: https://github.com/apache/trafficserver/pull/12956#discussion_r2919623810
##########
tools/hrw4u/src/hrw_visitor.py:
##########
@@ -407,10 +395,27 @@ def _close_if_and_section(self) -> None:
def _ensure_section_open(self, section_label: SectionType) -> None:
"""Ensure a section is open for statements."""
if not self._section_opened:
+ relocated_lines = None
+ relocated_if_depth = 0
+ if self._if_depth > 0 and self._pre_section_if_start is not None:
+ relocated_lines = self.output[self._pre_section_if_start:]
+ relocated_if_depth = self._if_depth
+ self.output = self.output[:self._pre_section_if_start]
+ self.stmt_indent -= self._if_depth
+ self._if_depth = 0
Review Comment:
`stmt_indent` is being adjusted by `_if_depth`, which assumes they share the
same unit (indent *levels*). Elsewhere indentation is also handled via
`increase_indent()` and by constructing space prefixes from
`SystemDefaults.INDENT_SPACES`, which suggests potential unit-mismatch (levels
vs spaces). To make this robust and easier to reason about, prefer
snapshotting/restoring the previous `stmt_indent` (and restoring via existing
indent helpers) rather than doing arithmetic between `stmt_indent` and
`_if_depth`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]