From aa7e1e46f8a85abff6461412ec77513fa4c0061d Mon Sep 17 00:00:00 2001 From: eeeXun Date: Sat, 22 Oct 2022 01:50:59 +0800 Subject: [PATCH] fix swap, if box do not have words, no need to cut last char --- ui.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui.go b/ui.go index ecee221..2344746 100644 --- a/ui.go +++ b/ui.go @@ -125,7 +125,12 @@ func TranslatePageHandler(event *tcell.EventKey) *tcell.EventKey { updateTitle() src_text := src_box.GetText() dst_text := dst_box.GetText(false) - src_box.SetText(dst_text[:len(dst_text)-1], true) + if len(dst_text) > 0 { + // GetText of Box contains "\n" if it has words + src_box.SetText(dst_text[:len(dst_text)-1], true) + } else { + src_box.SetText(dst_text, true) + } dst_box.SetText(src_text) }