Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 1651ae6

Browse files
author
Yuncong Zhang
committed
Handle Back Delete.
1 parent c873951 commit 1651ae6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Runtime/rendering/editable.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,20 @@ void _handleShortcuts(KeyCommand cmd) {
501501
void _handleDelete() {
502502
var selection = this.selection;
503503
if (selection.textAfter(this.text.text).isNotEmpty()) {
504-
this.textSelectionDelegate.textEditingValue = new TextEditingValue(
505-
text: selection.textBefore(this.text.text)
506-
+ selection.textAfter(this.text.text).Substring(1),
507-
selection: TextSelection.collapsed(offset: selection.start)
508-
);
504+
if (char.IsLowSurrogate(this.text.text[selection.end])) {
505+
this.textSelectionDelegate.textEditingValue = new TextEditingValue(
506+
text: selection.textBefore(this.text.text)
507+
+ selection.textAfter(this.text.text).Substring(2),
508+
selection: TextSelection.collapsed(offset: selection.start)
509+
);
510+
}
511+
else {
512+
this.textSelectionDelegate.textEditingValue = new TextEditingValue(
513+
text: selection.textBefore(this.text.text)
514+
+ selection.textAfter(this.text.text).Substring(1),
515+
selection: TextSelection.collapsed(offset: selection.start)
516+
);
517+
}
509518
}
510519
else {
511520
this.textSelectionDelegate.textEditingValue = new TextEditingValue(

0 commit comments

Comments
 (0)