handle delete with null context before

This commit is contained in:
sgschantz 2022-03-14 13:00:44 +07:00
parent e5628b66fb
commit a3202e0ff9

View file

@ -287,7 +287,7 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate {
return
}
// What the actual heck, Apple. Apparently, in system-keyboard mode, this is also self-triggered if we erase back to a newline.
// Apparently, in system-keyboard mode, this is also self-triggered if we erase back to a newline.
// Refer to https://github.com/keymanapp/keyman/pull/2770 for context.
if self.swallowBackspaceTextChange && Manager.shared.isSystemKeyboard && textDocumentProxy.documentContextBeforeInput == "\n" {
self.swallowBackspaceTextChange = false
@ -333,6 +333,11 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate {
return
}
if numCharsToDelete > 0 && textDocumentProxy.documentContextBeforeInput == nil {
textDocumentProxy.deleteBackward()
return
}
for _ in 0..<numCharsToDelete {
let oldContext = textDocumentProxy.documentContextBeforeInput ?? ""
textDocumentProxy.deleteBackward()