mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Don't assign text grammar by default. Just use the null grammar.
This commit is contained in:
@@ -23,8 +23,8 @@ describe "the `syntax` global", ->
|
||||
expect(syntax.selectGrammar("file.js").name).toBe "JavaScript" # based on extension (.js)
|
||||
expect(syntax.selectGrammar("/tmp/.git/config").name).toBe "Git Config" # based on end of the path (.git/config)
|
||||
expect(syntax.selectGrammar("Rakefile").name).toBe "Ruby" # based on the file's basename (Rakefile)
|
||||
expect(syntax.selectGrammar("curb").name).toBe "Plain Text"
|
||||
expect(syntax.selectGrammar("/hu.git/config").name).toBe "Plain Text"
|
||||
expect(syntax.selectGrammar("curb").name).toBe "Null Grammar"
|
||||
expect(syntax.selectGrammar("/hu.git/config").name).toBe "Null Grammar"
|
||||
|
||||
it "uses the filePath's shebang line if the grammar cannot be determined by the extension or basename", ->
|
||||
filePath = require.resolve("fixtures/shebang")
|
||||
@@ -37,7 +37,7 @@ describe "the `syntax` global", ->
|
||||
expect(syntax.selectGrammar("dummy.coffee", fileContent).name).toBe "CoffeeScript"
|
||||
|
||||
fileContent = '<?xml version="1.0" encoding="UTF-8"?>'
|
||||
expect(syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Plain Text"
|
||||
expect(syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Null Grammar"
|
||||
|
||||
fileContent += '\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
|
||||
expect(syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Property List (XML)"
|
||||
|
||||
@@ -43,12 +43,10 @@ class TextMateGrammar
|
||||
contents = fsUtils.read(path) if not contents? and fsUtils.isFile(path)
|
||||
|
||||
if syntax.grammarOverrideForPath(path) is @scopeName
|
||||
Infinity
|
||||
else if @matchesContents(contents)
|
||||
3
|
||||
else if @matchesPath(path)
|
||||
else if @matchesContents(contents)
|
||||
2
|
||||
else if @isTextGrammar()
|
||||
else if @matchesPath(path)
|
||||
1
|
||||
else
|
||||
-1
|
||||
@@ -78,9 +76,6 @@ class TextMateGrammar
|
||||
pathSuffix = pathComponents[-fileTypeComponents.length..-1]
|
||||
_.isEqual(pathSuffix, fileTypeComponents)
|
||||
|
||||
isTextGrammar: ->
|
||||
@scopeName is 'text.plain'
|
||||
|
||||
tokenizeLine: (line, ruleStack=[@initialRule], firstLine=false) ->
|
||||
originalRuleStack = ruleStack
|
||||
ruleStack = new Array(ruleStack...) # clone ruleStack
|
||||
|
||||
Reference in New Issue
Block a user