diff --git a/keymaps/darwin.cson b/keymaps/darwin.cson index facd6cc8e..a112bfbf7 100644 --- a/keymaps/darwin.cson +++ b/keymaps/darwin.cson @@ -1,4 +1,4 @@ -'.platform-darwin': +'body': # Apple specific 'cmd-q': 'application:quit' 'cmd-h': 'application:hide' @@ -87,7 +87,7 @@ 'cmd-8': 'pane:show-item-8' 'cmd-9': 'pane:show-item-9' -'.platform-darwin .editor': +'.editor': # Apple Specific 'cmd-backspace': 'editor:backspace-to-beginning-of-line' 'cmd-delete': 'editor:backspace-to-beginning-of-line' @@ -113,7 +113,7 @@ 'cmd-k cmd-l': 'editor:lower-case' 'cmd-l': 'editor:select-line' -'body.platform-darwin .editor:not(.mini)': +'.workspace .editor:not(.mini)': # Atom specific 'alt-cmd-z': 'editor:checkout-head-revision' 'cmd-<': 'editor:scroll-to-cursor' @@ -148,7 +148,7 @@ 'cmd-k cmd-9': 'editor:fold-at-indent-level-9' # allow standard input fields to work correctly -'body.platform-darwin .native-key-bindings': +'body .native-key-bindings': 'cmd-z': 'native!' 'cmd-Z': 'native!' 'cmd-x': 'native!' diff --git a/keymaps/win32.cson b/keymaps/win32.cson index 60825bf16..3b6a230a5 100644 --- a/keymaps/win32.cson +++ b/keymaps/win32.cson @@ -1,4 +1,4 @@ -'.platform-win32': +'body': # Atom Specific 'enter': 'core:confirm' 'escape': 'core:cancel' @@ -50,7 +50,7 @@ 'ctrl-k ctrl-left': 'window:focus-previous-pane' 'ctrl-k ctrl-right': 'window:focus-next-pane' -'.platform-win32 .editor': +'.workspace .editor': # Windows specific 'ctrl-delete': 'editor:backspace-to-beginning-of-word' @@ -60,7 +60,7 @@ 'ctrl-k ctrl-u': 'editor:upper-case' 'ctrl-k ctrl-l': 'editor:lower-case' -'.platform-win32 .editor:not(.mini)': +'.workspace .editor:not(.mini)': # Atom specific 'alt-ctrl-z': 'editor:checkout-head-revision' 'ctrl-<': 'editor:scroll-to-cursor' @@ -94,7 +94,7 @@ 'ctrl-k ctrl-9': 'editor:fold-at-indent-level-9' # allow standard input fields to work correctly -'.platform-win32 input:not(.hidden-input), .platform-win32 .native-key-bindings': +'body .native-key-bindings': 'ctrl-z': 'native!' 'ctrl-Z': 'native!' 'ctrl-x': 'native!' diff --git a/spec/keymap-spec.coffee b/spec/keymap-spec.coffee index d976144ed..064c5b1c7 100644 --- a/spec/keymap-spec.coffee +++ b/spec/keymap-spec.coffee @@ -354,6 +354,27 @@ describe "Keymap", -> bindings = keymap.keyBindingsForCommandMatchingElement('cultivate', el) expect(bindings).toHaveLength 0 + describe "loading platform specific keybindings", -> + customKeymap = null + + beforeEach -> + resourcePath = temp.mkdirSync('atom') + customKeymap = new Keymap({configDirPath, resourcePath}) + + afterEach -> + customKeymap.destroy() + + it "doesn't load keybindings from other platforms", -> + win32FilePath = path.join(resourcePath, "keymaps", "win32.cson") + darwinFilePath = path.join(resourcePath, "keymaps", "darwin.cson") + fs.writeFileSync(win32FilePath, '"body": "ctrl-l": "core:win32-move-left"') + fs.writeFileSync(darwinFilePath, '"body": "ctrl-l": "core:darwin-move-left"') + + customKeymap.loadBundledKeymaps() + keyBindings = customKeymap.keyBindingsForKeystroke('ctrl-l') + expect(keyBindings).toHaveLength 1 + expect(keyBindings[0].command).toBe "core:#{process.platform}-move-left" + describe "when the user keymap file is changed", -> it "is reloaded", -> keymapFilePath = path.join(configDirPath, "keymap.cson") diff --git a/src/keymap.coffee b/src/keymap.coffee index e75faf17d..3c3a8ec44 100644 --- a/src/keymap.coffee +++ b/src/keymap.coffee @@ -142,7 +142,12 @@ class Keymap @userKeymapFile.on 'contents-changed moved removed', => @loadUserKeymap() loadDirectory: (directoryPath) -> - @load(filePath) for filePath in fs.listSync(directoryPath, ['.cson', '.json']) + platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32'] + otherPlatforms = platforms.filter (name) -> name != process.platform + + for filePath in fs.listSync(directoryPath, ['.cson', '.json']) + continue if path.basename(filePath, path.extname(filePath)) in otherPlatforms + @load(filePath) load: (path) -> @add(path, CSON.readFileSync(path)) diff --git a/vendor/apm b/vendor/apm index b80ef23ce..50d23f5f4 160000 --- a/vendor/apm +++ b/vendor/apm @@ -1 +1 @@ -Subproject commit b80ef23ce8d2a1e8b4f40eb0f89c87f32dcc3415 +Subproject commit 50d23f5f419230cf1833e7bb8ee7bf0d7289ab1d