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

Commit 834775b

Browse files
author
Yuncong Zhang
committed
Fix delete bug.
1 parent 5774b99 commit 834775b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Runtime/service/keyboard.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ public void OnGUI() {
108108
currentEvent.Use();
109109
}
110110

111-
if (this._value != oldValue) {
111+
if (this._value != oldValue) {
112112
Window.instance.run(() => { TextInput._updateEditingState(this._client, this._value); });
113-
}
113+
}
114114
}
115115

116116
public void Dispose() {

Runtime/service/text_input.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,23 @@ public TextEditingValue deleteSelection(bool backDelete = true) {
258258
return this;
259259
}
260260

261+
if (char.IsHighSurrogate(this.text[this.selection.start - 1])) {
262+
return this.copyWith(
263+
text: this.text.Substring(0, this.selection.start - 1) +
264+
this.text.Substring(this.selection.start + 1),
265+
selection: TextSelection.collapsed(this.selection.start - 1),
266+
composing: TextRange.empty);
267+
}
268+
269+
if (char.IsLowSurrogate(this.text[this.selection.start - 1])) {
270+
D.assert(this.selection.start > 1);
271+
return this.copyWith(
272+
text: this.text.Substring(0, this.selection.start - 2) +
273+
this.selection.textAfter(this.text),
274+
selection: TextSelection.collapsed(this.selection.start - 2),
275+
composing: TextRange.empty);
276+
}
277+
261278
return this.copyWith(
262279
text: this.text.Substring(0, this.selection.start - 1) + this.selection.textAfter(this.text),
263280
selection: TextSelection.collapsed(this.selection.start - 1),

0 commit comments

Comments
 (0)