fix(review-loop-run): CR-10 — scope exits only on headings shallower-or-equal to start depth (8c865eb4-7fd1-4a8d-b51d-04d020ba41c0)
This commit is contained in:
@@ -41,15 +41,25 @@ report_dir_for() {
|
||||
|
||||
# _counts_scope <file> → prints the text of the last "count by severity"
|
||||
# section (heading matching /count.*severity|severity.*count|summary/i, up
|
||||
# to the next heading or EOF), or the last 40 lines if no such heading exists.
|
||||
# to the next heading of the same or shallower depth or EOF), or the last
|
||||
# 40 lines if no such heading exists.
|
||||
# CR-10 (bug 8c865eb4): Only headings of depth <= the starting heading's
|
||||
# depth terminate the scope; a deeper sub-heading (e.g. `###` under a `##`
|
||||
# section) is part of the section and must NOT cut scope short.
|
||||
_counts_scope() {
|
||||
local f="$1"
|
||||
local hdr_line
|
||||
hdr_line=$(grep -inE 'count.*severity|severity.*count|summary' "$f" | tail -1 | cut -d: -f1) || true
|
||||
if [[ -n "$hdr_line" ]]; then
|
||||
awk -v start="$hdr_line" '
|
||||
NR==start { found=1 }
|
||||
found && NR>start && /^#{1,4}[[:space:]]/ { exit }
|
||||
NR==start {
|
||||
found=1
|
||||
match($0, /^(#+)/, arr)
|
||||
hdr_level = length(arr[1])
|
||||
}
|
||||
found && NR>start {
|
||||
if (match($0, /^(#+)[[:space:]]/, arr) && length(arr[1]) <= hdr_level) exit
|
||||
}
|
||||
found { print }
|
||||
' "$f"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user