       @runMovementKeyChar @options.immediateMovement, @getCountPrefix()
       return
 
+    # Track the initial selection range.  We'll restore it if the user exits with Escape.
+    unless @options.parentMode
+      @initialRangeOnLaunch = options.initialRangeOnLaunch ||
+        (if @selection.type == "None" then "None" else @selection.getRangeAt 0)
+
     # This is the main keyboard-event handler for movements and commands.
     @push
       _name: "#{@id}/keypress"

        @movements.N = (count) -> executeFind count, true
        @movements["/"] = ->
          @findMode = enterFindMode()
          @findMode.onExit => new VisualMode
    #
    # End of Movement constructor.

  # Yank the selection; always exits; either deletes the selection or collapses it; set @yankedText and
  # returns it.

            for [0...count]
              unless window.find query, Utils.hasUpperCase(query), findBackwards, true, false, true, false
                @setSelectionRange initialRange
                HUD.showForDuration("No matches for '" + query + "'", 1000)
                return
            # The find was successfull. If we're in caret mode, then we should now have a selection, so we can
            # drop back into visual mode.
