mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #13549 from atom/io-user-keymap-event
Add did-load-user-keymap event
This commit is contained in:
23
spec/keymap-extensions-spec.coffee
Normal file
23
spec/keymap-extensions-spec.coffee
Normal 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()
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user