   focus: ->
     return if this.checkFocus()
     @root.focus()
-    if !this.getNativeRange() && @range?
-      this.setRange(@range)
+    this.setRange(@savedRange)
 
   getBounds: (index) ->
     pos = @doc.findPath(index).pop()

        this.setNativeRange(startNode, startOffset, endNode, endOffset)
    else
      this.setNativeRange(null)
    this.update(source)

  update: (args...) ->
    oldRange = @range
    @range = this.getRange()
    return if oldRange == @range
    if oldRange == null || @range == null || oldRange.start != @range.start || oldRange.end != @range.end
      this.onUpdate(@range, args...)


module.exports = Selection


  constructor: (@doc) ->
    @root = @doc.domNode
    @lastRange = @savedRange = new Range(1, 1)  # savedRange is never null
    ['keyup', 'mouseup', 'mouseleave', 'touchend', 'touchleave'].forEach((eventName) =>
      @root.addEventListener(eventName, =>
        this.update()  # Do not pass event handler params
