From 3f82d96b8e23dec2743bcca5f798af26f023123a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 21 Jun 2020 18:26:10 +1000 Subject: [PATCH] buffer history now: can't go out of bounds, can go to an empty line once you go past the most recent --- module/buffer.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/buffer.lua b/module/buffer.lua index 6acf1b6..b6805a3 100644 --- a/module/buffer.lua +++ b/module/buffer.lua @@ -294,9 +294,14 @@ function buffer:read(...) elseif char == "B" then -- down hIndex = hIndex - 1 io.write("\27[u"..(" "):rep(buffer:len()+1)) + if hIndex == 0 then + hIndex = hIndex - 1 + buffer = "" + end buffer = self.history[1+#self.history-hIndex] or buffer pos = 1 end + hIndex = math.max(math.min(hIndex,#self.history),0) end elseif char == "\8" then if #buffer > 0 and pos <= #buffer then