     return result
   }
 
-  public func hasMarkedText() -> Bool {
-    return self.markedText != nil
-  }
-
-  public func attributedSubstring(
+  func hasMarkedText() -> Bool { self.markedText != nil }
+
+  func attributedSubstring(
     forProposedRange aRange: NSRange,
-    actualRange: NSRangePointer?
+    actualRange _: NSRangePointer?
   ) -> NSAttributedString? {
-
     self.log.debug("\(aRange)")
-    if aRange.location == NSNotFound {
-      return nil
-    }
+    if aRange.location == NSNotFound { return nil }
 
     guard
-      let position = self.ugrid.firstPosition(
-        fromFlatCharIndex: aRange.location
-      ),
+      let position = self.ugrid.firstPosition(fromFlatCharIndex: aRange.location),
       let inclusiveEndPosition = self.ugrid.lastPosition(
         fromFlatCharIndex: aRange.location + aRange.length - 1
       )
-      else {
-      return nil
-    }
+    else { return nil }
 
     self.log.debug("\(position) ... \(inclusiveEndPosition)")
     let string = self.ugrid.cells[position.row...inclusiveEndPosition.row]
       .map { row in
         row.filter { cell in
-          return aRange.location <= cell.flatCharIndex
-                 && cell.flatCharIndex <= aRange.inclusiveEndIndex
+          aRange.location <= cell.flatCharIndex && cell.flatCharIndex <= aRange.inclusiveEndIndex
         }
       }
       .flatMap { $0 }
-      .map { $0.string }
+      .map(\.string)
       .joined()
 
     let delta = aRange.length - string.utf16.count
-    if delta != 0 {
-      self.log.debug("delta = \(delta)!")
-    }
+    if delta != 0 { self.log.debug("delta = \(delta)!") }
 
     self.log.debug("returning '\(string)'")
     return NSAttributedString(string: string)
   }
 
-  public func validAttributesForMarkedText() -> [NSAttributedString.Key] {
-    return []
-  }
-
-  public func firstRect(
-    forCharacterRange aRange: NSRange, actualRange: NSRangePointer?
-  ) -> NSRect {
-    guard let position = self.ugrid.firstPosition(
-      fromFlatCharIndex: aRange.location
-    ) else {
+  func validAttributesForMarkedText() -> [NSAttributedString.Key] { [] }
+
+  func firstRect(forCharacterRange aRange: NSRange, actualRange _: NSRangePointer?) -> NSRect {
+    guard let position = self.ugrid.firstPosition(fromFlatCharIndex: aRange.location) else {
       return CGRect.zero
     }
 
     self.log.debug("\(aRange)-> \(position.row):\(position.column)")
 
     let resultInSelf = self.rect(forRow: position.row, column: position.column)
-    let result = self.window?.convertToScreen(
-      self.convert(resultInSelf, to: nil)
-    )
+    let result = self.window?.convertToScreen(self.convert(resultInSelf, to: nil))
 
     return result!
   }
 
-  public func characterIndex(for aPoint: NSPoint) -> Int {
+  func characterIndex(for aPoint: NSPoint) -> Int {
     let position = self.position(at: aPoint)
     let result = self.ugrid.flatCharIndex(forPosition: position)
 


    let result: NSRange
    result = NSRange(
      location: self.ugrid.flatCharIndex(
        forPosition: self.ugrid.cursorPosition
      ),
      length: 0
    )


    self.keyDownDone = true
  }

  func insertText(_ object: Any, replacementRange: NSRange) {
    self.log.debug("\(object) with \(replacementRange)")

    let text: String
    switch object {
    case let string as String: text = string
    case let attributedString as NSAttributedString: text = attributedString.string
    default: return
    }

    let length = self.markedText?.count ?? 0
    try? self.bridge
      .deleteCharacters(length, andInputEscapedString: self.vimPlainString(text))
      .wait()

    if length > 0 {
      self.ugrid.unmarkCell(at: self.markedPosition)
      self.markForRender(position: self.markedPosition)
      if self.ugrid.isNextCellEmpty(self.markedPosition) {
        self.ugrid.unmarkCell(at: self.markedPosition.advancing(row: 0, column: 1))
        self.markForRender(position: self.markedPosition.advancing(row: 0, column: 1))
      }
    }

