mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Move grammar overrides to syntax (no serialization yet)
This commit is contained in:
committed by
Nathan Sobo
parent
dacb00ed67
commit
db4420e068
@@ -2036,14 +2036,10 @@ describe "Editor", ->
|
||||
|
||||
it "updates all the rendered lines when the grammar changes", ->
|
||||
editor.edit(project.buildEditSession(path))
|
||||
|
||||
expect(editor.getGrammar().name).toBe 'Plain Text'
|
||||
jsGrammar = syntax.selectGrammar('/tmp/js.js')
|
||||
expect(jsGrammar.name).toBe 'JavaScript'
|
||||
|
||||
project.addGrammarOverrideForPath(path, jsGrammar)
|
||||
syntax.setGrammarOverrideForPath(path, 'source.js')
|
||||
expect(editor.reloadGrammar()).toBeTruthy()
|
||||
expect(editor.getGrammar()).toBe jsGrammar
|
||||
expect(editor.getGrammar().name).toBe 'JavaScript'
|
||||
|
||||
tokenizedBuffer = editor.activeEditSession.displayBuffer.tokenizedBuffer
|
||||
line0 = tokenizedBuffer.lineForScreenRow(0)
|
||||
@@ -2067,10 +2063,8 @@ describe "Editor", ->
|
||||
|
||||
expect(eventHandler).not.toHaveBeenCalled()
|
||||
|
||||
jsGrammar = syntax.selectGrammar('/tmp/js.js')
|
||||
project.addGrammarOverrideForPath(path, jsGrammar)
|
||||
syntax.setGrammarOverrideForPath(path, 'source.js')
|
||||
editor.reloadGrammar()
|
||||
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
describe ".replaceSelectedText()", ->
|
||||
|
||||
@@ -260,9 +260,6 @@ describe "Project", ->
|
||||
range: [[1, 3], [1, 5]]
|
||||
|
||||
describe "serialization", ->
|
||||
it "restores the project path and grammar overrides", ->
|
||||
jsGrammar = _.find syntax.grammars, (grammar) -> grammar.name is 'JavaScript'
|
||||
project.addGrammarOverrideForPath('/a/b.txt', jsGrammar)
|
||||
it "restores the project path", ->
|
||||
newProject = Project.deserialize(project.serialize())
|
||||
expect(newProject.getPath()).toBe project.getPath()
|
||||
expect(newProject.grammarOverrideForPath('/a/b.txt')).toBe jsGrammar
|
||||
|
||||
@@ -30,6 +30,13 @@ describe "the `syntax` global", ->
|
||||
expect(syntax.selectGrammar(filePath, filePathContents).name).toBe "Ruby"
|
||||
expect(fs.read).not.toHaveBeenCalled()
|
||||
|
||||
it "allows the default grammar to be overridden for a path", ->
|
||||
path = '/foo/bar/file.js'
|
||||
expect(syntax.selectGrammar(path).name).not.toBe 'Ruby'
|
||||
syntax.setGrammarOverrideForPath(path, 'source.ruby')
|
||||
expect(syntax.selectGrammar(path).name).toBe 'Ruby'
|
||||
syntax.clearGrammarOverrideForPath(path)
|
||||
expect(syntax.selectGrammar(path).name).not.toBe 'Ruby'
|
||||
|
||||
describe ".getProperty(scopeDescriptor)", ->
|
||||
it "returns the property with the most specific scope selector", ->
|
||||
|
||||
Reference in New Issue
Block a user