From efaf25230584e86098ca57edd683c1c563a95a99 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 30 Sep 2024 13:38:35 -0500 Subject: [PATCH] add another test case for stripAnsi --- src/hwylterm/bbansi.nim | 3 ++- tests/tbbansi.nim | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hwylterm/bbansi.nim b/src/hwylterm/bbansi.nim index 55fc21a..c9f2ac9 100644 --- a/src/hwylterm/bbansi.nim +++ b/src/hwylterm/bbansi.nim @@ -19,7 +19,8 @@ func stripAnsi*(s: string): string = while s[i] != 'm': inc i inc i - result.add s[i] + if i < s.len: + result.add s[i] inc i type diff --git a/tests/tbbansi.nim b/tests/tbbansi.nim index 2f92aae..b76a7df 100644 --- a/tests/tbbansi.nim +++ b/tests/tbbansi.nim @@ -66,6 +66,7 @@ suite "basic": suite "strutils": test "stripAnsi": + check stripAnsi($bb"[red]red!") == "red!" check stripAnsi("\e[1mBold String!") == "Bold String!" test "&":