mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
💄
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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', '<esc>': 'command-mode:activate'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user