aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2015-01-28 10:32:53 +0000
committerStephen Blott2015-01-28 12:03:50 +0000
commit786b8ba0854b71e7bee00248b3ee29da357ba8d0 (patch)
treef0182497cbd0e72605cbfcd418d6964dc2277d44 /lib
parentc117ac90faf8c685b40195ac54b237dfcb2b648b (diff)
downloadvimium-786b8ba0854b71e7bee00248b3ee29da357ba8d0.tar.bz2
Visual/edit modes: yet more minor changes.
- Use a has for singletons (as it was previously), but with a distinct identity generated by Utils.getIdentity. - Fix counts not be using in a number of places.
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.coffee23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index f8eb5457..c04bf417 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -152,19 +152,16 @@ Utils =
# locale-sensitive uppercase detection
hasUpperCase: (s) -> s.toLowerCase() != s
- # Allow a function call to be suppressed. Use Utils.suppress.unlessSuppressed to call a function, unless it
- # is suppressed via the given key. Use Utils.suppressor.suppress to call a function while suppressing the
- # given key.
- suppressor: do ->
- suppressed = {}
-
- suppress: (key, func) ->
- suppressed[key] = if suppressed[key]? then suppressed[key] + 1 else 1
- func()
- suppressed[key] -= 1
-
- unlessSuppressed: (key, func) ->
- func() unless suppressed[key]? and 0 < suppressed[key]
+ # Give objects (including elements) distinct identities.
+ getIdentity: do ->
+ identities = []
+
+ (obj) ->
+ index = identities.indexOf obj
+ if index < 0
+ index = identities.length
+ identities.push obj
+ "identity-" + index
# This creates a new function out of an existing function, where the new function takes fewer arguments. This
# allows us to pass around functions instead of functions + a partial list of arguments.