     // Refer to https://github.com/keymanapp/keyman/pull/2770 for context.
     if self.swallowBackspaceTextChange && Manager.shared.isSystemKeyboard && textDocumentProxy.documentContextBeforeInput == "\n" {
       self.swallowBackspaceTextChange = false
+      return
+    }
+
+    // Currently motivated by the need to shift caret position to perform
+    // right-deletions.
+    if self.swallowContextChangeCount > 0 {
+      self.swallowContextChangeCount -= 1
       return
     }
     

      textDocumentProxy.insertText(newText)
    }

    // TODO: should probably 'swallow' caret position shifts throughout this block.
    for _ in 0..<numCharsToRightDelete {
      let oldContext = textDocumentProxy.documentContextAfterInput ?? ""
      textDocumentProxy.adjustTextPosition(byCharacterOffset: 1)
      textDocumentProxy.deleteBackward()
      let newContext = textDocumentProxy.documentContextAfterInput ?? ""

      let unitsDeleted = oldContext.utf16.count - newContext.utf16.count
      if unitsDeleted > 1 {
        if !InputViewController.isSurrogate(oldContext.utf16.first!) {
          let lowerIndex = oldContext.utf16.index(oldContext.utf16.startIndex,
                                                  offsetBy: 1)
          let upperIndex = oldContext.utf16.index(lowerIndex, offsetBy: unitsDeleted - 1)
          let remnant = String(oldContext.utf16[lowerIndex..<upperIndex]) ?? ""
          textDocumentProxy.insertText(remnant)

          // Must place the caret back in its correct position!
          textDocumentProxy.adjustTextPosition(byCharacterOffset: -remnant.count)
        }
      }
    }
  }


  private var keymanWeb: KeymanWebViewController
  
  private var swallowBackspaceTextChange: Bool = false
  private var swallowContextChangeCount: Int = 0

  open class var isPortrait: Bool {
    return UIScreen.main.bounds.width < UIScreen.main.bounds.height
