mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Remove a package's keymaps when it is deactivated
This commit is contained in:
parent
5410e9368f
commit
1e51750b6c
@ -150,6 +150,12 @@ describe "the `atom` global", ->
|
||||
expect(syntax.selectGrammar('a.alot').name).toBe 'Null Grammar'
|
||||
expect(syntax.selectGrammar('a.alittle').name).toBe 'Null Grammar'
|
||||
|
||||
it "removes the package's keymaps", ->
|
||||
atom.activatePackage('package-with-keymaps')
|
||||
atom.deactivatePackage('package-with-keymaps')
|
||||
expect(keymap.bindingsForElement($$ -> @div class: 'test-1')['ctrl-z']).toBeUndefined()
|
||||
expect(keymap.bindingsForElement($$ -> @div class: 'test-2')['ctrl-z']).toBeUndefined()
|
||||
|
||||
describe "texmate packages", ->
|
||||
it "removes the package's grammars", ->
|
||||
expect(syntax.selectGrammar("file.rb").name).toBe "Null Grammar"
|
||||
|
@ -32,7 +32,7 @@ class AtomPackage extends Package
|
||||
this
|
||||
|
||||
activate: ({immediate}={}) ->
|
||||
keymap.add(map) for map in @keymaps
|
||||
keymap.add(path, map) for [path, map] in @keymaps
|
||||
applyStylesheet(path, content) for [path, content] in @stylesheets
|
||||
syntax.addGrammar(grammar) for grammar in @grammars
|
||||
|
||||
@ -55,21 +55,17 @@ class AtomPackage extends Package
|
||||
@metadata ?= {}
|
||||
|
||||
loadKeymaps: ->
|
||||
@keymaps = []
|
||||
@keymaps = @getKeymapPaths().map (path) -> [path, CSON.readObject(path)]
|
||||
|
||||
getKeymapPaths: ->
|
||||
keymapsDirPath = fsUtils.join(@path, 'keymaps')
|
||||
keymapExtensions = ['cson', 'json', '']
|
||||
|
||||
if @metadata.keymaps
|
||||
for path in @metadata.keymaps
|
||||
@keymaps.push(CSON.readObject(fsUtils.resolve(keymapsDirPath, path, keymapExtensions)))
|
||||
@metadata.keymaps.map (name) -> fsUtils.resolve(keymapsDirPath, name, ['cson', 'json', ''])
|
||||
else
|
||||
for path in fsUtils.list(keymapsDirPath, ['cson', 'json', '']) ? []
|
||||
@keymaps.push(CSON.readObject(path))
|
||||
fsUtils.list(keymapsDirPath, ['cson', 'json']) ? []
|
||||
|
||||
loadStylesheets: ->
|
||||
@stylesheets = []
|
||||
@stylesheets.push([path, loadStylesheet(path)]) for path in @getStylesheetPaths()
|
||||
@stylesheets = @getStylesheetPaths().map (path) -> [path, loadStylesheet(path)]
|
||||
|
||||
getStylesheetPaths: ->
|
||||
stylesheetDirPath = fsUtils.join(@path, 'stylesheets')
|
||||
@ -98,6 +94,7 @@ class AtomPackage extends Package
|
||||
|
||||
deactivate: ->
|
||||
syntax.removeGrammar(grammar) for grammar in @grammars
|
||||
keymap.remove(path) for [path] in @keymaps
|
||||
@mainModule?.deactivate?()
|
||||
|
||||
requireMainModule: ->
|
||||
|
Loading…
Reference in New Issue
Block a user