on main help sign in
fix(ui): simplify suffix handling in message editor
01c0524Ayman Bagabas
internal/ui/model/ui.go+2−2
@@ -813,9 +813,9 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
813 switch {
813 switch {
814 case key.Matches(msg, m.keyMap.Editor.SendMessage):
814 case key.Matches(msg, m.keyMap.Editor.SendMessage):
815 value := m.textarea.Value()
815 value := m.textarea.Value()
816− if strings.HasSuffix(value, "\\") {
816+ if before, ok := strings.CutSuffix(value, "\\"); ok {
817 // If the last character is a backslash, remove it and add a newline.
817 // If the last character is a backslash, remove it and add a newline.
818− m.textarea.SetValue(strings.TrimSuffix(value, "\\"))
818+ m.textarea.SetValue(before)
819 break
819 break
820 }
820 }
821
821