We're working on a keyboard extension and I've encountered this weird bug on microsoft office word (we haven't seen it anywhere else yet...) where the the text received from super.textDocumentProxy.documentContextAfterInput
simply is out of sync with the current cursor position.
I don't get how that is even possible but the result is pretty consistent.
At the start of step 3 the cursor should be at 'Tomorrow |' (Cursor marked with '|') but the documentContextAfterInput will be '\0'. Now I can handle that but if I keep inserting text from suggestions we get 1 random char from the text instead of what it actually should be (nil or empty). The problem is the afterInput is completely inconsistent with the current cursor position. I've even tried moving the cursor to the start of the text and then to the end (same result).
Luckily the BeforeInput method works flawlessly...
Now any suggestions to how I can workaround, fix or explain this will be greatly appreciated.
Edit: I'm starting to suspect that it is due to character encoding or microsoft carriage return somehow getting broken.
Multiple issues is the cause of this. First: microsoft do use some kind of hidden characters. Second: iOS application have some control about how to handle movecursor which can conflict with how keyboard-extension would expect it to work. This will usually not give any major issues as most keyboard-extension are fairly simple, but if you like us make complex text analyzation and handling you will get some buggy behaviour.