Fix bug that caused the last character to be dropped when inputting a new character
@@ -235,7 +235,15 @@ func NewEditor() *Editor {
}
if len(right) == 0 {
+ if len(selection) == 1 {
+ if string(selection) == selectionChar {
editor.setAndFixText(fmt.Sprintf("[\"left\"]%s%s[\"\"][\"selection\"]%s[\"\"]", string(left), (string)(character), string(selectionChar)))
+ } else {
+ editor.setAndFixText(fmt.Sprintf("[\"left\"]%s%s[\"\"][\"selection\"]%s[\"\"]", string(left), (string)(character), string(selection)))
+ }
+ } else {
+ editor.setAndFixText(fmt.Sprintf("[\"left\"]%s%s[\"\"][\"selection\"]%s[\"\"]", string(left), (string)(character), string(selectionChar)))
+ }
} else {
editor.setAndFixText(fmt.Sprintf("[\"left\"]%s%s[\"\"][\"selection\"]%s[\"\"][\"right\"]%s[\"\"]",
string(left), string(character), string(selection), string(right)))
