From 88fd6f01b9709834d50397617200b7f62b413716 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 5 Mar 2022 08:28:34 -0400 Subject: [PATCH] fix: dont add last empty line of history, make sure first isnt missing in search --- history.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/history.go b/history.go index 81a8705..2a7c496 100644 --- a/history.go +++ b/history.go @@ -20,8 +20,13 @@ func newFileHistory() (*fileHistory, error) { } } - var itms []string - for _, l := range strings.Split(string(data), "\n") { + itms := []string{""} + lines := strings.Split(string(data), "\n") + for i, l := range lines { + if i == len(lines) - 1 { + println(i, l) + continue + } itms = append(itms, l) } f, err := os.OpenFile(defaultHistPath, os.O_RDWR | os.O_CREATE, 0755)