aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/mode_insert.coffee12
-rw-r--r--content_scripts/vimium_frontend.coffee2
2 files changed, 7 insertions, 7 deletions
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee
index 91103a55..eac4a3d0 100644
--- a/content_scripts/mode_insert.coffee
+++ b/content_scripts/mode_insert.coffee
@@ -1,12 +1,9 @@
class InsertMode extends Mode
- # There is one permanently-installed instance of InsertMode. It tracks focus changes and
- # activates/deactivates itself (by setting @insertModeLock) accordingly.
- @permanentInstance: null
-
constructor: (options = {}) ->
- InsertMode.permanentInstance ||= @
- @permanent = (@ == InsertMode.permanentInstance)
+ # There is one permanently-installed instance of InsertMode. It tracks focus changes and
+ # activates/deactivates itself (by setting @insertModeLock) accordingly.
+ @permanent = options.permanent
# If truthy, then we were activated by the user (with "i").
@global = options.global
@@ -51,6 +48,9 @@ class InsertMode extends Mode
if @insertModeLock != event.target and DomUtils.isFocusable event.target
@activateOnElement event.target
+ # Only for tests. This gives us a hook to test the status of the permanent instance.
+ InsertMode.permanentInstance = @ if @permanent
+
isActive: (event) ->
return false if event == InsertMode.suppressedEvent
return true if @insertModeLock or @global
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 35d92f3c..fdd36ab9 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -124,7 +124,7 @@ initializePreDomReady = ->
# activates/deactivates itself accordingly.
new NormalMode
new PassKeysMode
- new InsertMode
+ new InsertMode permanent: true
checkIfEnabledForUrl()