From dd1a58f5037bce952b4be84eda94c369f58d01a9 Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Tue, 31 Oct 2023 11:33:47 -0400 Subject: [PATCH] fix: don't crash on missing data --- pkg/mux/screen/replay/time.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/mux/screen/replay/time.go b/pkg/mux/screen/replay/time.go index 6a976930..8b5fc371 100644 --- a/pkg/mux/screen/replay/time.go +++ b/pkg/mux/screen/replay/time.go @@ -45,12 +45,14 @@ func (r *Replay) setIndex(index, indexByte int, updateTime bool) { toByte = geom.Clamp(toByte, 0, len(data)-1) } - if fromIndex == toIndex { - data = data[fromByte+1 : toByte+1] - } else if fromIndex == i { - data = data[fromByte+1:] - } else if toIndex == i { - data = data[:toByte+1] + if len(data) > 0 { + if fromIndex == toIndex { + data = data[fromByte+1 : toByte+1] + } else if fromIndex == i { + data = data[fromByte+1:] + } else if toIndex == i { + data = data[:toByte+1] + } } r.terminal.Write(data)