@@ -90,6 +90,7 @@ public TextInputResponder(AvaloniaView view, TextInputMethodClient client)
90
90
private int _inSurroundingTextUpdateEvent ;
91
91
private readonly UITextPosition _beginningOfDocument = new AvaloniaTextPosition ( 0 ) ;
92
92
private readonly UITextInputStringTokenizer _tokenizer ;
93
+ private bool _isInUpdate ;
93
94
94
95
public TextInputMethodClient ? Client => _client ;
95
96
@@ -142,15 +143,15 @@ public override UITextInputMode TextInputMode
142
143
private void SurroundingTextChanged ( object ? sender , EventArgs e )
143
144
{
144
145
Logger . TryGet ( LogEventLevel . Debug , ImeLog ) ? . Log ( null , "SurroundingTextChanged" ) ;
145
- if ( WeakInputDelegate == null )
146
+ if ( WeakInputDelegate == null || _isInUpdate )
146
147
return ;
147
148
_inSurroundingTextUpdateEvent ++ ;
148
149
try
149
150
{
150
151
objc_msgSend ( WeakInputDelegate . Handle . Handle , TextWillChange , Handle . Handle ) ;
151
152
objc_msgSend ( WeakInputDelegate . Handle . Handle , TextDidChange , Handle . Handle ) ;
152
- objc_msgSend ( WeakInputDelegate . Handle . Handle , SelectionWillChange , this . Handle . Handle ) ;
153
- objc_msgSend ( WeakInputDelegate . Handle . Handle , SelectionDidChange , this . Handle . Handle ) ;
153
+ objc_msgSend ( WeakInputDelegate . Handle . Handle , SelectionWillChange , Handle . Handle ) ;
154
+ objc_msgSend ( WeakInputDelegate . Handle . Handle , SelectionDidChange , Handle . Handle ) ;
154
155
}
155
156
finally
156
157
{
@@ -180,6 +181,7 @@ private void TextInput(string text)
180
181
181
182
void IUIKeyInput . InsertText ( string text )
182
183
{
184
+ _isInUpdate = true ;
183
185
Logger . TryGet ( LogEventLevel . Debug , ImeLog ) ? . Log ( null , "IUIKeyInput.InsertText {text}" , text ) ;
184
186
185
187
if ( text == "\n " )
@@ -203,9 +205,15 @@ void IUIKeyInput.InsertText(string text)
203
205
}
204
206
205
207
TextInput ( text ) ;
208
+ _isInUpdate = false ;
206
209
}
207
210
208
- void IUIKeyInput . DeleteBackward ( ) => KeyPress ( Key . Back , PhysicalKey . Backspace , "\b " ) ;
211
+ void IUIKeyInput . DeleteBackward ( )
212
+ {
213
+ _isInUpdate = true ;
214
+ KeyPress ( Key . Back , PhysicalKey . Backspace , "\b " ) ;
215
+ _isInUpdate = false ;
216
+ }
209
217
210
218
bool IUIKeyInput . HasText => true ;
211
219
0 commit comments