diff --git a/record.go b/record.go index 4f003c45c..9fcf5c22a 100644 --- a/record.go +++ b/record.go @@ -152,6 +152,9 @@ func inputToTape(input string) string { repeat := 1 for lines[i] == lines[i+repeat] { repeat++ + if i+repeat == len(lines) { + break + } } i += repeat - 1 diff --git a/record_test.go b/record_test.go index 8bd5f1d6c..ea9b26dee 100644 --- a/record_test.go +++ b/record_test.go @@ -66,3 +66,12 @@ func TestInputToTapeLongSleep(t *testing.T) { t.Fatalf("want:\n%s\ngot:\n%s\n", want, got) } } + +func TestInputToTape_RepeatedSleepAfterExit(t *testing.T) { + input := "SLEEP\nexit\nSLEEP\nSLEEP" + want := "Sleep 500ms\nType \"exit\"\nSleep 1s\n" + got := inputToTape(input) + if want != got { + t.Fatalf("want:\n%s\ngot:\n%s\n", want, got) + } +}