From 3e0378d0bc5d85ffec0ef49f7c421edbe9c073ec Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 14 Jan 2015 12:43:41 +0000 Subject: Modes; rework PostFindMode (again). --- content_scripts/mode_insert.coffee | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'content_scripts/mode_insert.coffee') diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 4be9c589..89077c6a 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -1,6 +1,11 @@ class InsertMode extends Mode + # There is one permanently-installed instance of InsertMode. This allows PostFindMode to query its state. + @permanentInstance: null + constructor: (options = {}) -> + InsertMode.permanentInstance ||= @ + defaults = name: "insert" keydown: (event) => @handleKeydownEvent event @@ -51,12 +56,8 @@ class InsertMode extends Mode exit: (target) -> if target == undefined or target == @insertModeLock - if @options.targetElement? - super() - else - # If @options.targetElement isn't set, then this is the permanently-installed instance from the front - # end. So, we don't actually exit; instead, we just reset ourselves. - @insertModeLock = null + # If this is the permanently-installed instance, then we don't actually exit; instead, we just reset. + if @ == InsertMode.permanentInstance then @insertModeLock = null else super() chooseBadge: (badge) -> badge.badge ||= "I" if @isActive() -- cgit v1.2.3