mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Add tokenized event to tokenized buffer
This commit is contained in:
@@ -385,6 +385,20 @@ describe "TokenizedBuffer", ->
|
||||
expect(tokens[1].value).toBeTruthy()
|
||||
expect(tokens[2].value).toBe 'xyz'
|
||||
|
||||
describe "when the grammar tokenized", ->
|
||||
it "emits the `tokenized` event", ->
|
||||
buffer = null
|
||||
tokenizedBuffer = null
|
||||
tokenizedHandler = jasmine.createSpy("tokenized handler")
|
||||
|
||||
waitsForPromise ->
|
||||
atom.project.open('sample.js').then (editor) -> buffer = editor.getBuffer()
|
||||
|
||||
runs ->
|
||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||
tokenizedBuffer.on 'tokenized', tokenizedHandler
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
expect(tokenizedHandler.callCount).toBe(1)
|
||||
describe "when the grammar is updated because a grammar it includes is activated", ->
|
||||
it "retokenizes the buffer", ->
|
||||
|
||||
|
||||
@@ -124,7 +124,10 @@ class TokenizedBuffer extends Model
|
||||
@invalidateRow(row + 1) unless filledRegion
|
||||
@emit "changed", { start: invalidRow, end: row, delta: 0 }
|
||||
|
||||
@tokenizeInBackground() if @firstInvalidRow()?
|
||||
if @firstInvalidRow()?
|
||||
@tokenizeInBackground()
|
||||
else
|
||||
@emit "tokenized"
|
||||
|
||||
firstInvalidRow: ->
|
||||
@invalidRows[0]
|
||||
|
||||
Reference in New Issue
Block a user