v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-17 00:00:16 -07:00

fix swap, if box do not have words, no need to cut last char

This commit is contained in:
eeeXun 2022-10-22 01:50:59 +08:00
parent 681f349fc4
commit aa7e1e46f8

7
ui.go
View File

@ -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)
}