From 86d7a91dcddeac1e0400a4cb1e3553cac0666205 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 12 Jan 2012 17:56:49 -0800 Subject: [PATCH] :lipstick: --- spec/atom/vim-mode-spec.coffee | 2 +- src/atom/binding-set.coffee | 22 +++++++++------------- src/atom/vim-mode.coffee | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/spec/atom/vim-mode-spec.coffee b/spec/atom/vim-mode-spec.coffee index 22da7e256..c6c581410 100644 --- a/spec/atom/vim-mode-spec.coffee +++ b/spec/atom/vim-mode-spec.coffee @@ -13,7 +13,7 @@ describe "VimMode", -> it "puts the editor in command-mode initially", -> expect(editor).toHaveClass 'command-mode' - fdescribe "command-mode", -> + describe "command-mode", -> it "stops propagation on key events that don't have bindings so that they don't get inserted", -> event = keydownEvent('\\') spyOn(event, 'stopPropagation') diff --git a/src/atom/binding-set.coffee b/src/atom/binding-set.coffee index f4afbd51c..4ccae9b40 100644 --- a/src/atom/binding-set.coffee +++ b/src/atom/binding-set.coffee @@ -1,5 +1,5 @@ -_ = require 'underscore' $ = require 'jquery' +_ = require 'underscore' Specificity = require 'specificity' module.exports = @@ -12,21 +12,17 @@ class BindingSet '=': 187, ';': 186, '\'': 222, '[': 219, ']': 221, '\\': 220 selector: null - bindingMap: null - bindingFunction: null + commandForEvent: null constructor: (@selector, mapOrFunction) -> - if _.isFunction(mapOrFunction) - @bindingFunction = mapOrFunction - else - @bindingMap = mapOrFunction @specificity = Specificity(@selector) - - commandForEvent: (event) -> - return @bindingFunction(event) if @bindingFunction - for pattern, command of @bindingMap - return command if @eventMatchesPattern(event, pattern) - null + if _.isFunction(mapOrFunction) + @commandForEvent = mapOrFunction + else + @commandForEvent = (event) => + for pattern, command of mapOrFunction + return command if @eventMatchesPattern(event, pattern) + null eventMatchesPattern: (event, pattern) -> pattern = @parseKeyPattern pattern diff --git a/src/atom/vim-mode.coffee b/src/atom/vim-mode.coffee index c2fd11b71..c2b38ddab 100644 --- a/src/atom/vim-mode.coffee +++ b/src/atom/vim-mode.coffee @@ -9,7 +9,7 @@ class VimMode constructor: (@editor) -> @opStack = [] - atom.bindKeys '.command-mode', > false + atom.bindKeys '.command-mode', -> false atom.bindKeys '.command-mode', @commandModeBindings() atom.bindKeys '.insert-mode', '': 'command-mode:activate'