Merge pull request #13549 from atom/io-user-keymap-event

Add did-load-user-keymap event
This commit is contained in:
Ian Olsen
2017-01-06 11:32:07 -08:00
committed by GitHub
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
path = require 'path'
temp = require('temp').track()
CSON = require 'season'
fs = require 'fs-plus'
describe "keymap-extensions", ->
beforeEach ->
atom.keymaps.configDirPath = temp.path('atom-spec-keymap-ext')
fs.writeFileSync(atom.keymaps.getUserKeymapPath(), '#')
@userKeymapLoaded = ->
atom.keymaps.onDidLoadUserKeymap => @userKeymapLoaded()
afterEach ->
fs.removeSync(atom.keymaps.configDirPath)
atom.keymaps.destroy()
describe "did-load-user-keymap", ->
it "fires when user keymap is loaded", ->
spyOn(this, 'userKeymapLoaded')
atom.keymaps.loadUserKeymap()
expect(@userKeymapLoaded).toHaveBeenCalled()

View File

@@ -8,6 +8,9 @@ bundledKeymaps = require('../package.json')?._atomKeymaps
KeymapManager::onDidLoadBundledKeymaps = (callback) ->
@emitter.on 'did-load-bundled-keymaps', callback
KeymapManager::onDidLoadUserKeymap = (callback) ->
@emitter.on 'did-load-user-keymap', callback
KeymapManager::loadBundledKeymaps = ->
keymapsPath = path.join(@resourcePath, 'keymaps')
if bundledKeymaps?
@@ -49,6 +52,9 @@ KeymapManager::loadUserKeymap = ->
stack = error.stack
@notificationManager.addFatalError(error.message, {detail, stack, dismissable: true})
@emitter.emit 'did-load-user-keymap'
KeymapManager::subscribeToFileReadFailure = ->
@onDidFailToReadFile (error) =>
userKeymapPath = @getUserKeymapPath()