diff options
Diffstat (limited to 'content_scripts/mode_find.coffee')
| -rw-r--r-- | content_scripts/mode_find.coffee | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 6b4f6bb1..35352277 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -1,6 +1,7 @@ -# NOTE(smblott). Ultimately, all of the FindMode-related code should be moved to this file. +# NOTE(smblott). Ultimately, all of the FindMode-related code should be moved here. -# This prevents printable characters from being passed through to underlying page; see #1415. +# This prevents unmapped printable characters from being passed through to underlying page; see #1415. Only +# used by PostFindMode, below. class SuppressPrintable extends Mode constructor: (options) -> super options @@ -9,20 +10,20 @@ class SuppressPrintable extends Mode # We use unshift here, so we see events after normal mode, so we only see unmapped keys. @unshift - _name: "mode-#{@id}/suppressPrintableEvents" + _name: "mode-#{@id}/suppress-printable" keydown: handler keypress: handler keyup: (event) => - # If the selection types has changed (usually, no longer "Range"), then the user is interacting with + # If the selection type has changed (usually, no longer "Range"), then the user is interacting with # the input element, so we get out of the way. See discussion of option 5c from #1415. if document.getSelection().type != type then @exit() else handler event -# When we use find mode, the selection/focus can land in a focusable/editable element. In this situation, -# special considerations apply. We implement three special cases: +# When we use find, the selection/focus can land in a focusable/editable element. In this situation, special +# considerations apply. We implement three special cases: # 1. Disable insert mode, because the user hasn't asked to enter insert mode. We do this by using # InsertMode.suppressEvent. -# 2. Prevent printable keyboard events from propagating to the page; see #1415. We do this by inheriting -# from SuppressPrintable. +# 2. Prevent unmapped printable keyboard events from propagating to the page; see #1415. We do this by +# inheriting from SuppressPrintable. # 3. If the very-next keystroke is Escape, then drop immediately into insert mode. # class PostFindMode extends SuppressPrintable @@ -39,7 +40,8 @@ class PostFindMode extends SuppressPrintable keypress: (event) -> InsertMode.suppressEvent event keyup: (event) -> InsertMode.suppressEvent event - # If the very-next keydown is Esc, drop immediately into insert mode. + # If the very-next keydown is Escape, then exit immediately, thereby passing subsequent keys to the + # underlying insert-mode instance. self = @ @push _name: "mode-#{@id}/handle-escape" @@ -53,7 +55,7 @@ class PostFindMode extends SuppressPrintable true # Continue bubbling. # If PostFindMode is active, then we suppress the "I" badge from insert mode. - updateBadge: (badge) -> InsertMode.suppressEvent badge + updateBadge: (badge) -> InsertMode.suppressEvent badge # Always truthy. root = exports ? window root.PostFindMode = PostFindMode |
