aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-02-02 16:56:07 +0000
committerStephen Blott2015-02-02 16:56:07 +0000
commit95e086563b918364d3038f6489cc97c73fcb7180 (patch)
treeec204a30822362b054e880d348e8021cb0668592
parent03f764098aeef114679facfc22104faf141cf3c1 (diff)
downloadvimium-95e086563b918364d3038f6489cc97c73fcb7180.tar.bz2
Visual/edit modes: Escape-Escape clears selection.
-rw-r--r--content_scripts/mode_visual_edit.coffee23
1 files changed, 20 insertions, 3 deletions
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee
index 69d4a0a6..caecfbde 100644
--- a/content_scripts/mode_visual_edit.coffee
+++ b/content_scripts/mode_visual_edit.coffee
@@ -362,9 +362,6 @@ class Movement extends CountPrefix
#
# End of Movement constructor.
- exit: (event, target) ->
- super event, target
-
# Yank the selection; always exits; either deletes the selection or collapses it; set @yankedText and
# returns it.
yank: (args = {}) ->
@@ -384,6 +381,26 @@ class Movement extends CountPrefix
@exit()
@yankedText
+ exit: (event, target) ->
+ unless @options.parentMode or @options.oneMovementOnly
+ # If we're exiting on escape and there is a range selection, then we leave it in place. However, an
+ # immediately-following Escape clears the selection. See #1441.
+ if @selection.type == "Range" and event?.type == "keydown" and KeyboardUtils.isEscape event
+ handlerStack.push
+ _name: "visual/range/escape"
+ click: -> handlerStack.remove()
+ focus: -> handlerStack.remove()
+ keydown: (event) =>
+ handlerStack.remove()
+ if @selection.type == "Range" and event.type == "keydown" and KeyboardUtils.isEscape event
+ @collapseSelectionToFocus()
+ DomUtils.suppressKeyupAfterEscape handlerStack
+ @suppressEvent
+ else
+ @continueBubbling
+
+ super event, target
+
# For "daw", "das", and so on. We select a lexical entity (a word, a sentence or a paragraph).
# Note(smblott). It would be better if the entities could be handled symmetrically. Unfortunately, they
# cannot, and we have to handle each case individually.