     }
 
     setContextState(text: context, range: NSRange(newRange, in: context))
+  }
+  
+  @objc func clearSwallowFlag() {
+    self.swallowBackspaceTextChange = false
   }
 
   func insertText(_ keymanWeb: KeymanWebViewController, numCharsToDelete: Int, newText: String) {

        }
      }
    }

    if !newText.isEmpty {
      textDocumentProxy.insertText(newText)

  }

  open override func textDidChange(_ textInput: UITextInput?) {
    // Swallows self-triggered calls from emptying the context due to keyboard rules
    if self.swallowBackspaceTextChange {
      self.swallowBackspaceTextChange = false
      return
    }
    
    let contextBeforeInput = textDocumentProxy.documentContextBeforeInput ?? ""
    let contextAfterInput = textDocumentProxy.documentContextAfterInput ?? ""
    let context = "\(contextBeforeInput)\(contextAfterInput)"
