diff options
| author | Stephen Blott | 2015-01-03 07:29:35 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-03 08:03:45 +0000 |
| commit | 734d16a457c0f18edcf3c951752f5e16ed2199e9 (patch) | |
| tree | e822b361e14febee4070d2c7b0c36d51a565a63a /content_scripts | |
| parent | 103fcde7c51fe83bc9c58fc28c3c11ce6a791f0f (diff) | |
| download | vimium-734d16a457c0f18edcf3c951752f5e16ed2199e9.tar.bz2 | |
Modes; fix #1410.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/mode_insert.coffee | 1 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 36 |
2 files changed, 23 insertions, 14 deletions
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 64aaa445..ed5d0023 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -50,6 +50,7 @@ class InsertMode extends Mode super name: "insert" keydown: (event) => + return @continueBubbling if event.suppressInsertMode return @continueBubbling unless @isActive() return @stopBubblingAndTrue unless KeyboardUtils.isEscape event # We're now exiting insert mode. diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a252c878..0f23af05 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -726,6 +726,8 @@ handleEnterForFindMode = -> focusFoundLink() document.body.classList.add("vimiumFindMode") settings.set("findModeRawQuery", findModeQuery.rawQuery) + # If we have found an input element, the pressing <esc> immediately afterwards sends us into insert mode. + new PostFindMode() class FindMode extends Mode constructor: (badge="F") -> @@ -759,6 +761,25 @@ class FindMode extends Mode Mode.updateBadge() +# If find lands in an editable element, then "Esc" drops us into insert mode. +class PostFindMode extends Mode + constructor: (element) -> + super + keydown: (event) => + @exit() + if (KeyboardUtils.isEscape(event)) + DomUtils.simulateSelect(document.activeElement) + insertMode.activate() + return @suppressEvent # we have "consumed" this event, so do not propagate + event.suppressInsertMode = true + return @continueBubbling + + elementCanTakeInput = document.activeElement && + DomUtils.isSelectable(document.activeElement) && + isDOMDescendant(findModeAnchorNode, document.activeElement) + elementCanTakeInput ||= document.activeElement?.isContentEditable + @exit() unless elementCanTakeInput + performFindInPlace = -> cachedScrollX = window.scrollX cachedScrollY = window.scrollY @@ -855,20 +876,7 @@ findAndFocus = (backwards) -> # if we have found an input element via 'n', pressing <esc> immediately afterwards sends us into insert # mode - elementCanTakeInput = document.activeElement && - DomUtils.isSelectable(document.activeElement) && - isDOMDescendant(findModeAnchorNode, document.activeElement) - if (elementCanTakeInput) - handlerStack.push({ - keydown: (event) -> - @remove() - if (KeyboardUtils.isEscape(event)) - DomUtils.simulateSelect(document.activeElement) - enterInsertModeWithoutShowingIndicator(document.activeElement) - insertMode.activate() - return false # we have "consumed" this event, so do not propagate - return true - }) + new PostFindMode() focusFoundLink() |
