nimble0 / dotterel

Dotterel is a free, open source program that provides the ability to use stenographic input on the Android platform.
GNU General Public License v2.0
85 stars 6 forks source link

Interleaved deletion and insertion order is incorrect in Termux #22

Closed user202729 closed 3 years ago

user202729 commented 3 years ago

For example: when I type U/TAOUB, on the second stroke (deletion of 3 characters) and(insertion of "YouTube") is executed, sometimes the insertion is done before the deletion, results in "youYouT".

This occasionally happen on termux, and never happens on other applications as far as I can see.

Related: LibreOffice on Linux (Plover) has the same issue. https://github.com/openstenoproject/plover/issues/1059 avoid linking

Plover has a workaround (currently not merged into master, and might not ever be) to delay between the key presses.

I didn't take a look at the code to see if it's really a problem with the input method (and there's a proper way to do it), or termux-specific bug -- in that case the delay would would be a workaround...

user202729 commented 3 years ago

Looks like a Termux bug.

Workaround (diff) ```diff --- a/app/src/main/java/nimble/dotterel/Dotterel.kt +++ b/app/src/main/java/nimble/dotterel/Dotterel.kt @@ -285,6 +285,9 @@ class Dotterel : InputMethodService(), StenoMachine.Listener // InputConnection.deleteSurroundingText should not delete // half of a surrogate pair or nonexistent characters. this.deleteSurroundingText(a.backspaces, 0) + this.endBatchEdit() + Thread.sleep(20) + this.beginBatchEdit() this.commitText(a.text, 1) this.endBatchEdit() }) ```