mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge remote-tracking branch 'origin/master' into ns-less-memory-for-tokens
This commit is contained in:
14
package.json
14
package.json
@@ -87,7 +87,7 @@
|
||||
"autocomplete-atom-api": "0.9.0",
|
||||
"autocomplete-css": "0.7.2",
|
||||
"autocomplete-html": "0.7.2",
|
||||
"autocomplete-plus": "2.16.3",
|
||||
"autocomplete-plus": "2.17.0",
|
||||
"autocomplete-snippets": "1.6.1",
|
||||
"autoflow": "0.23.0",
|
||||
"autosave": "0.20.0",
|
||||
@@ -99,7 +99,7 @@
|
||||
"dev-live-reload": "0.46.0",
|
||||
"encoding-selector": "0.20.0",
|
||||
"exception-reporting": "0.24.0",
|
||||
"find-and-replace": "0.163.0",
|
||||
"find-and-replace": "0.166.0",
|
||||
"fuzzy-finder": "0.85.0",
|
||||
"git-diff": "0.55.0",
|
||||
"go-to-line": "0.30.0",
|
||||
@@ -110,8 +110,8 @@
|
||||
"link": "0.30.0",
|
||||
"markdown-preview": "0.149.0",
|
||||
"metrics": "0.48.0",
|
||||
"notifications": "0.46.0",
|
||||
"open-on-github": "0.36.0",
|
||||
"notifications": "0.47.0",
|
||||
"open-on-github": "0.37.0",
|
||||
"package-generator": "0.39.0",
|
||||
"release-notes": "0.52.0",
|
||||
"settings-view": "0.199.0",
|
||||
@@ -128,7 +128,7 @@
|
||||
"whitespace": "0.29.0",
|
||||
"wrap-guide": "0.33.0",
|
||||
"language-c": "0.44.0",
|
||||
"language-clojure": "0.14.0",
|
||||
"language-clojure": "0.15.0",
|
||||
"language-coffee-script": "0.40.0",
|
||||
"language-csharp": "0.5.0",
|
||||
"language-css": "0.29.0",
|
||||
@@ -147,8 +147,8 @@
|
||||
"language-perl": "0.24.0",
|
||||
"language-php": "0.23.0",
|
||||
"language-property-list": "0.8.0",
|
||||
"language-python": "0.34.0",
|
||||
"language-ruby": "0.52.0",
|
||||
"language-python": "0.35.0",
|
||||
"language-ruby": "0.53.0",
|
||||
"language-ruby-on-rails": "0.21.0",
|
||||
"language-sass": "0.38.0",
|
||||
"language-shellscript": "0.15.0",
|
||||
|
||||
11
spec/fixtures/packages/package-with-rb-filetype/grammars/rb.cson
vendored
Normal file
11
spec/fixtures/packages/package-with-rb-filetype/grammars/rb.cson
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'name': 'Test Ruby'
|
||||
'scopeName': 'test.rb'
|
||||
'fileTypes': [
|
||||
'rb'
|
||||
]
|
||||
'patterns': [
|
||||
{
|
||||
'match': 'ruby'
|
||||
'name': 'meta.class.ruby'
|
||||
}
|
||||
]
|
||||
4
spec/fixtures/packages/package-with-rb-filetype/package.json
vendored
Normal file
4
spec/fixtures/packages/package-with-rb-filetype/package.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "package-with-rb-filetype",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -2,7 +2,7 @@ path = require 'path'
|
||||
fs = require 'fs-plus'
|
||||
temp = require 'temp'
|
||||
|
||||
describe "the `syntax` global", ->
|
||||
describe "the `grammars` global", ->
|
||||
beforeEach ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('language-text')
|
||||
@@ -25,9 +25,9 @@ describe "the `syntax` global", ->
|
||||
filePath = '/foo/bar/file.js'
|
||||
expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby'
|
||||
atom.grammars.setGrammarOverrideForPath(filePath, 'source.ruby')
|
||||
syntax2 = atom.deserializers.deserialize(atom.grammars.serialize())
|
||||
syntax2.addGrammar(grammar) for grammar in atom.grammars.grammars when grammar isnt atom.grammars.nullGrammar
|
||||
expect(syntax2.selectGrammar(filePath).name).toBe 'Ruby'
|
||||
grammars2 = atom.deserializers.deserialize(atom.grammars.serialize())
|
||||
grammars2.addGrammar(grammar) for grammar in atom.grammars.grammars when grammar isnt atom.grammars.nullGrammar
|
||||
expect(grammars2.selectGrammar(filePath).name).toBe 'Ruby'
|
||||
|
||||
describe ".selectGrammar(filePath)", ->
|
||||
it "can use the filePath to load the correct grammar based on the grammar's filetype", ->
|
||||
@@ -94,6 +94,16 @@ describe "the `syntax` global", ->
|
||||
grammar2 = atom.grammars.loadGrammarSync(grammarPath2)
|
||||
expect(atom.grammars.selectGrammar('more.test', '')).toBe grammar2
|
||||
|
||||
it "favors non-bundled packages when breaking scoring ties", ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'packages', 'package-with-rb-filetype'))
|
||||
|
||||
runs ->
|
||||
atom.grammars.grammarForScopeName('source.ruby').bundledPackage = true
|
||||
atom.grammars.grammarForScopeName('test.rb').bundledPackage = false
|
||||
|
||||
expect(atom.grammars.selectGrammar('test.rb').scopeName).toBe 'test.rb'
|
||||
|
||||
describe "when there is no file path", ->
|
||||
it "does not throw an exception (regression)", ->
|
||||
expect(-> atom.grammars.selectGrammar(null, '#!/usr/bin/ruby')).not.toThrow()
|
||||
@@ -53,7 +53,7 @@ class AutoUpdateManager
|
||||
@emitUpdateAvailableEvent(@getWindows()...)
|
||||
|
||||
# Only released versions should check for updates.
|
||||
@check(hidePopups: true) unless /\w{7}/.test(@version)
|
||||
@scheduleUpdateCheck() unless /\w{7}/.test(@version)
|
||||
|
||||
switch process.platform
|
||||
when 'win32'
|
||||
@@ -75,6 +75,12 @@ class AutoUpdateManager
|
||||
getState: ->
|
||||
@state
|
||||
|
||||
scheduleUpdateCheck: ->
|
||||
checkForUpdates = => @check(hidePopups: true)
|
||||
fourHours = 1000 * 60 * 60 * 4
|
||||
setInterval(checkForUpdates, fourHours)
|
||||
checkForUpdates()
|
||||
|
||||
check: ({hidePopups}={}) ->
|
||||
unless hidePopups
|
||||
autoUpdater.once 'update-not-available', @onUpdateNotAvailable
|
||||
|
||||
@@ -35,7 +35,17 @@ class GrammarRegistry extends FirstMate.GrammarRegistry
|
||||
# * `fileContents` A {String} of text for the file path.
|
||||
#
|
||||
# Returns a {Grammar}, never null.
|
||||
selectGrammar: (filePath, fileContents) -> super
|
||||
selectGrammar: (filePath, fileContents) ->
|
||||
bestMatch = null
|
||||
highestScore = -Infinity
|
||||
for grammar in @grammars
|
||||
score = grammar.getScore(filePath, fileContents)
|
||||
if score > highestScore or not bestMatch?
|
||||
bestMatch = grammar
|
||||
highestScore = score
|
||||
else if score is highestScore and bestMatch?.bundledPackage
|
||||
bestMatch = grammar unless grammar.bundledPackage
|
||||
bestMatch
|
||||
|
||||
clearObservers: ->
|
||||
@off() if includeDeprecatedAPIs
|
||||
|
||||
@@ -303,6 +303,7 @@ class Package
|
||||
try
|
||||
grammar = atom.grammars.readGrammarSync(grammarPath)
|
||||
grammar.packageName = @name
|
||||
grammar.bundledPackage = @bundledPackage
|
||||
@grammars.push(grammar)
|
||||
grammar.activate()
|
||||
catch error
|
||||
@@ -322,6 +323,7 @@ class Package
|
||||
atom.notifications.addFatalError("Failed to load a #{@name} package grammar", {stack, detail, dismissable: true})
|
||||
else
|
||||
grammar.packageName = @name
|
||||
grammar.bundledPackage = @bundledPackage
|
||||
@grammars.push(grammar)
|
||||
grammar.activate() if @grammarsActivated
|
||||
callback()
|
||||
|
||||
Reference in New Issue
Block a user