Upgrade first-mate for event subscription methods

This commit is contained in:
Nathan Sobo 2014-09-10 17:24:55 -06:00
parent f0a19e3f67
commit d55f5cba78
3 changed files with 12 additions and 9 deletions

View File

@ -28,7 +28,7 @@
"delegato": "^1",
"emissary": "^1.3.1",
"event-kit": "0.7.1",
"first-mate": "^2.0.6",
"first-mate": "^2.1.0",
"fs-plus": "^2.2.6",
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",

View File

@ -137,7 +137,7 @@ afterEach ->
jasmine.unspy(atom, 'saveSync')
ensureNoPathSubscriptions()
atom.syntax.off()
atom.syntax.clearObservers()
waits(0) # yield to ui thread to make screen update more frequently
ensureNoPathSubscriptions = ->

View File

@ -27,12 +27,8 @@ class TokenizedBuffer extends Model
@tabLength ?= atom.config.getPositiveInt('editor.tabLength', 2)
@subscribe atom.syntax, 'grammar-added grammar-updated', (grammar) =>
if grammar.injectionSelector?
@retokenizeLines() if @hasTokenForSelector(grammar.injectionSelector)
else
newScore = grammar.getScore(@buffer.getPath(), @buffer.getText())
@setGrammar(grammar, newScore) if newScore > @currentGrammarScore
@subscribe atom.syntax.onDidAddGrammar(@grammarAddedOrUpdated)
@subscribe atom.syntax.onDidUpdateGrammar(@grammarAddedOrUpdated)
@subscribe @buffer.onDidChange (e) => @handleBufferChange(e)
@subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
@ -75,12 +71,19 @@ class TokenizedBuffer extends Model
EmitterMixin::on.apply(this, arguments)
grammarAddedOrUpdated: (grammar) =>
if grammar.injectionSelector?
@retokenizeLines() if @hasTokenForSelector(grammar.injectionSelector)
else
newScore = grammar.getScore(@buffer.getPath(), @buffer.getText())
@setGrammar(grammar, newScore) if newScore > @currentGrammarScore
setGrammar: (grammar, score) ->
return if grammar is @grammar
@unsubscribe(@grammar) if @grammar
@grammar = grammar
@currentGrammarScore = score ? grammar.getScore(@buffer.getPath(), @buffer.getText())
@subscribe @grammar, 'grammar-updated', => @retokenizeLines()
@subscribe @grammar.onDidUpdate => @retokenizeLines()
@retokenizeLines()
@emit 'grammar-changed', grammar
@emitter.emit 'did-change-grammar', grammar