From 990bccbff7b271e7c95de001741e07ac26ed5091 Mon Sep 17 00:00:00 2001 From: bagas Date: Fri, 5 Dec 2025 22:24:46 +0700 Subject: [PATCH] update: handle message deletion properly --- session/interaction/interaction.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/session/interaction/interaction.go b/session/interaction/interaction.go index 3f3db3f..181b3a4 100644 --- a/session/interaction/interaction.go +++ b/session/interaction/interaction.go @@ -44,6 +44,7 @@ type Forwarder interface { } type Interaction struct { + InputLength int CommandBuffer *bytes.Buffer EditMode bool EditSlug string @@ -96,13 +97,18 @@ func (i *Interaction) HandleUserInput() { i.SendMessage(string(buf[:n])) if char == 8 || char == 127 { + if i.InputLength > 0 { + //i.CommandBuffer.Truncate(i.CommandBuffer.Len() - 1) + i.SendMessage("\b \b") + } if i.CommandBuffer.Len() > 0 { i.CommandBuffer.Truncate(i.CommandBuffer.Len() - 1) - i.SendMessage("\b \b") } continue } + i.InputLength += n + if char == '/' { i.CommandBuffer.Reset() i.CommandBuffer.WriteByte(char) @@ -111,6 +117,7 @@ func (i *Interaction) HandleUserInput() { if i.CommandBuffer.Len() > 0 { if char == 13 { + i.SendMessage("\033[K") i.HandleCommand(i.CommandBuffer.String()) continue }