The .net RichTextBox inherits this problem, which means accessing its Text, Rtf, and Lines properties will clear the queues. What's more, calling its GetCharIndexFromPosition and GetPositionFromCharIndex functions will also clear the queues. Why is that? Don't GetCharIndexFromPosition and GetPositionFromCharIndex just wrap EM_CHARFROMPOS and EM_POSFROMCHAR?
Workarounds?
- Replace functions GetCharIndexFromPosition / GetPositionFromCharIndex with EM_CHARFROMPOS / EM_POSFROMCHAR
- Replace property Text with EM_GETTEXTEX / RichTextBox.SelectAll / SelectedText
- Replace property Lines with EM_GETTEXTEX / String.Split / Join
- Replace property Rtf with... no idea.