Skip to content

Commit cb5b5ce

Browse files
committed
fix(msgfmt): address review — extract border helper, add slim box test, drop plans
- Extract containsHorizontalBorder() to collapse 6 inline border checks into one — no more copy-paste miscounts on 15-char Unicode strings - Add msg_slim_dashed_box.txt fixture with │ prompt to exercise findGenericSlimMessageBox's ╌ path (previously untested because the > fixture hit findGreaterThanMessageBox first) - Rename screen → message in test lambda for consistency - Remove docs/plans/ from the branch
1 parent 934e832 commit cb5b5ce

5 files changed

Lines changed: 19 additions & 273 deletions

File tree

docs/plans/issue-209-research.md

Lines changed: 0 additions & 215 deletions
This file was deleted.

docs/plans/issue-209.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/msgfmt/message_box.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import (
44
"strings"
55
)
66

7+
// containsHorizontalBorder reports whether the line contains a
8+
// horizontal border made of box-drawing characters (─ or ╌).
9+
func containsHorizontalBorder(line string) bool {
10+
return strings.Contains(line, "───────────────") ||
11+
strings.Contains(line, "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌")
12+
}
13+
714
// Usually something like
815
// ─────────────── (or ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌)
916
// >
@@ -12,7 +19,7 @@ import (
1219
func findGreaterThanMessageBox(lines []string) int {
1320
for i := len(lines) - 1; i >= max(len(lines)-6, 0); i-- {
1421
if strings.Contains(lines[i], ">") {
15-
if i > 0 && (strings.Contains(lines[i-1], "───────────────") || strings.Contains(lines[i-1], "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌")) {
22+
if i > 0 && containsHorizontalBorder(lines[i-1]) {
1623
return i - 1
1724
}
1825
return i
@@ -27,9 +34,9 @@ func findGreaterThanMessageBox(lines []string) int {
2734
// ─────────────── (or ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌)
2835
func findGenericSlimMessageBox(lines []string) int {
2936
for i := len(lines) - 3; i >= max(len(lines)-9, 0); i-- {
30-
if (strings.Contains(lines[i], "───────────────") || strings.Contains(lines[i], "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌")) &&
37+
if containsHorizontalBorder(lines[i]) &&
3138
(strings.Contains(lines[i+1], "|") || strings.Contains(lines[i+1], "│") || strings.Contains(lines[i+1], "❯")) &&
32-
(strings.Contains(lines[i+2], "───────────────") || strings.Contains(lines[i+2], "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌")) {
39+
containsHorizontalBorder(lines[i+2]) {
3340
return i
3441
}
3542
}

0 commit comments

Comments
 (0)