aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-01-31 14:25:47 +0000
committerStephen Blott2015-01-31 14:25:47 +0000
commit847aca4859567aaa88e19d41139d236102bc2024 (patch)
tree4799c30aceea3830be78c156f11e324008844be6
parentd03ba099fcbe5e07dfdfa454afdb86fd5aad2c89 (diff)
downloadvimium-847aca4859567aaa88e19d41139d236102bc2024.tar.bz2
Visual/edit modes: exit visual mode on click in input element.
-rw-r--r--content_scripts/mode_visual_edit.coffee18
1 files changed, 15 insertions, 3 deletions
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee
index a170a2da..00c842ed 100644
--- a/content_scripts/mode_visual_edit.coffee
+++ b/content_scripts/mode_visual_edit.coffee
@@ -449,15 +449,20 @@ class VisualMode extends Movement
@changeMode CaretMode
return
- # Yank on <Enter>.
@push
- _name: "#{@id}/enter"
+ _name: "#{@id}/enter/click"
+ # Yank on <Enter>.
keypress: (event) =>
if event.keyCode == keyCodes.enter
unless event.metaKey or event.ctrlKey or event.altKey or event.shiftKey
@yank()
return @suppressEvent
@continueBubbling
+ # Click in a focusable element exits.
+ click: (event) =>
+ @alwaysContinueBubbling =>
+ unless @options.parentMode
+ @exit event, event.target if DomUtils.isFocusable event.target
# Visual-mode commands.
unless @options.oneMovementOnly
@@ -494,7 +499,7 @@ class VisualMode extends Movement
# Don't leave the user in insert mode just because they happen to have selected text within an input
# element.
if document.activeElement and DomUtils.isEditable document.activeElement
- document.activeElement.blur()
+ document.activeElement.blur() unless event?.type == "click"
super event, target
if @yankedText?
@@ -554,6 +559,13 @@ class CaretMode extends Movement
@selection.modify "extend", forward, character
@scrollIntoView()
+ @push
+ _name: "#{@id}/click"
+ # Click in a focusable element exits.
+ click: (event) =>
+ @alwaysContinueBubbling =>
+ @exit event, event.target if DomUtils.isFocusable event.target
+
extend @commands,
v: -> @changeMode VisualMode
V: -> @changeMode VisualLineMode