Merge branch 'master' into tree-sitter-injections

This commit is contained in:
Max Brunsfeld
2018-07-05 09:55:31 -07:00
5 changed files with 36 additions and 4 deletions

View File

@@ -12,7 +12,7 @@
"url": "https://github.com/atom/atom/issues"
},
"license": "MIT",
"electronVersion": "2.0.2",
"electronVersion": "2.0.4",
"dependencies": {
"@atom/nsfw": "^1.0.18",
"@atom/watcher": "1.0.3",
@@ -92,7 +92,7 @@
"solarized-dark-syntax": "1.1.5",
"solarized-light-syntax": "1.1.5",
"about": "1.9.1",
"archive-view": "0.65.0",
"archive-view": "0.65.1",
"autocomplete-atom-api": "0.10.7",
"autocomplete-css": "0.17.5",
"autocomplete-html": "0.8.4",
@@ -121,7 +121,7 @@
"line-ending-selector": "0.7.7",
"link": "0.31.4",
"markdown-preview": "0.159.20",
"metrics": "1.3.0",
"metrics": "1.4.3",
"notifications": "0.70.5",
"open-on-github": "1.3.1",
"package-generator": "1.3.0",

View File

@@ -14,6 +14,7 @@ module.exports = function () {
path.join(CONFIG.atomHomeDirPath, '.apm'),
path.join(CONFIG.atomHomeDirPath, '.npm'),
path.join(CONFIG.atomHomeDirPath, 'compile-cache'),
path.join(CONFIG.atomHomeDirPath, 'snapshot-cache'),
path.join(CONFIG.atomHomeDirPath, 'atom-shell'),
path.join(CONFIG.atomHomeDirPath, 'electron'),
path.join(os.tmpdir(), 'atom-build'),

View File

@@ -33,6 +33,8 @@ formatStackTrace = (spec, message='', stackTrace) ->
line = line.trim()
# at jasmine.Spec.<anonymous> (path:1:2) -> at path:1:2
.replace(/^at jasmine\.Spec\.<anonymous> \(([^)]+)\)/, 'at $1')
# at jasmine.Spec.it (path:1:2) -> at path:1:2
.replace(/^at jasmine\.Spec\.f*it \(([^)]+)\)/, 'at $1')
# at it (path:1:2) -> at path:1:2
.replace(/^at f*it \(([^)]+)\)/, 'at $1')
# at spec/file-test.js -> at file-test.js

View File

@@ -1299,6 +1299,34 @@ describe('Workspace', () => {
})
})
describe('the root-scope-used hook', () => {
it('fires when opening a file or changing the grammar of an open file', async () => {
await atom.packages.activatePackage('language-javascript')
await atom.packages.activatePackage('language-coffee-script')
const observeTextEditorsSpy = jasmine.createSpy('observeTextEditors')
const javascriptGrammarUsed = jasmine.createSpy('javascript')
const coffeeScriptGrammarUsed = jasmine.createSpy('coffeescript')
atom.packages.triggerDeferredActivationHooks()
atom.packages.onDidTriggerActivationHook('source.js:root-scope-used', () => {
atom.workspace.observeTextEditors(observeTextEditorsSpy)
javascriptGrammarUsed()
})
atom.packages.onDidTriggerActivationHook('source.coffee:root-scope-used', coffeeScriptGrammarUsed)
expect(javascriptGrammarUsed).not.toHaveBeenCalled()
expect(observeTextEditorsSpy).not.toHaveBeenCalled()
const editor = await atom.workspace.open('sample.js', {autoIndent: false})
expect(javascriptGrammarUsed).toHaveBeenCalled()
expect(observeTextEditorsSpy.callCount).toBe(1)
expect(coffeeScriptGrammarUsed).not.toHaveBeenCalled()
atom.grammars.assignLanguageMode(editor, 'source.coffee')
expect(coffeeScriptGrammarUsed).toHaveBeenCalled()
})
})
describe('::reopenItem()', () => {
it("opens the uri associated with the last closed pane that isn't currently open", () => {
const pane = workspace.getActivePane()

View File

@@ -1268,7 +1268,8 @@ module.exports = class Workspace extends Model {
handleGrammarUsed (grammar) {
if (grammar == null) { return }
return this.packageManager.triggerActivationHook(`${grammar.packageName}:grammar-used`)
this.packageManager.triggerActivationHook(`${grammar.scopeName}:root-scope-used`)
this.packageManager.triggerActivationHook(`${grammar.packageName}:grammar-used`)
}
// Public: Returns a {Boolean} that is `true` if `object` is a `TextEditor`.