From 58d0dabb71b5f7eb5a05966fcee44e224b5e5b8e Mon Sep 17 00:00:00 2001 From: Jean-Hadrien Chabran Date: Mon, 4 Mar 2024 22:01:37 +0100 Subject: [PATCH] fix: prevent typewriter for answers we already saw It you CodyToggle three times (on, off and on again), prompts sent by the user are not rendered as typewrited, but the answers from Cody will be, making the UI very annoying to deal with. This is a crude fix I did in between things during my evening, should be an okay bandage until we see if there's a better place to do this. Basically, if a messeag has been rendered, it assumes it's been completed. --- lua/sg/cody/state.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/sg/cody/state.lua b/lua/sg/cody/state.lua index 4bcb9760..4f885af1 100644 --- a/lua/sg/cody/state.lua +++ b/lua/sg/cody/state.lua @@ -160,6 +160,11 @@ function State:render(bufnr, win) message_state.typewriter:render(bufnr, win, message_state.mark, { interval = interval }) rendered = rendered + 1 + + -- /!\ TODO investigate, this is crude fix. + -- Basically, the messages the user type are marked as completed, but the answers from Cody + -- are never marked as such even after being displayed. Forcing it to true fixes it. + message.completed = true end for _, message_state in ipairs(self.messages) do