Skip to content

Commit 052e516

Browse files
committed
feat: better code formatting
1 parent f5641fe commit 052e516

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/msgfmt/message_box.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ func removeMessageBox(msg string) string {
5555
func removeCodexMessageBox(msg string) string {
5656
lines := strings.Split(msg, "\n")
5757
messageBoxEndIdx := -1
58-
messageBoxStartIdx := 0
58+
messageBoxStartIdx := -1
59+
5960
for i := len(lines) - 1; i >= 0; i-- {
6061
if messageBoxEndIdx == -1 {
6162
if strings.Contains(lines[i], "╰────────") && strings.Contains(lines[i], "───────╯") {
@@ -80,9 +81,16 @@ func removeCodexMessageBox(msg string) string {
8081
}
8182
}
8283

83-
if messageBoxEndIdx > messageBoxStartIdx {
84-
return strings.Join(lines[messageBoxStartIdx:messageBoxEndIdx], "\n")
84+
// If we didn't find messageBoxStartIdx, set it to 0
85+
if messageBoxStartIdx == -1 {
86+
messageBoxStartIdx = 0
8587
}
8688

87-
return strings.Join(lines, "\n")
89+
// If we didn't find messageBoxEndIdx, set it to the end of the lines
90+
if messageBoxEndIdx == -1 {
91+
messageBoxEndIdx = len(lines) - 1
92+
}
93+
94+
return strings.Join(lines[messageBoxStartIdx:messageBoxEndIdx], "\n")
95+
8896
}

0 commit comments

Comments
 (0)