aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/mode_visual.coffee7
-rw-r--r--content_scripts/vimium_frontend.coffee4
2 files changed, 8 insertions, 3 deletions
diff --git a/content_scripts/mode_visual.coffee b/content_scripts/mode_visual.coffee
index 011d6775..8c1fb5a4 100644
--- a/content_scripts/mode_visual.coffee
+++ b/content_scripts/mode_visual.coffee
@@ -235,9 +235,14 @@ class VisualMode extends KeyHandlerMode
keyMapping: keyMapping
commandHandler: @commandHandler.bind this
+ # If there was a range selection when the user lanuched visual mode, then we retain the selection on exit.
+ @shouldRetainSelectionOnExit = @options.userLaunchedMode and @selection.type == "Range"
+
@onExit (event = null) =>
+ if @shouldRetainSelectionOnExit
+ null # Retain any selection, regardless of how we exit.
# This mimics vim: when leaving visual mode via Escape, collapse to focus, otherwise collapse to anchor.
- if event?.type == "keydown" and KeyboardUtils.isEscape(event) and @name != "caret"
+ else if event?.type == "keydown" and KeyboardUtils.isEscape(event) and @name != "caret"
@movement.collapseSelectionToFocus()
else
@movement.collapseSelectionToAnchor()
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 6fb30dec..4dcdfe7d 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -358,10 +358,10 @@ extend window,
new InsertMode global: true, exitOnFocus: true
enterVisualMode: ->
- new VisualMode()
+ new VisualMode userLaunchedMode: true
enterVisualLineMode: ->
- new VisualLineMode
+ new VisualLineMod userLaunchedMode: true
passNextKey: (count) ->
new PassNextKeyMode count