2015-09-08 19:32:00 +03:00
|
|
|
TextBuffer = require 'text-buffer'
|
|
|
|
TokenizedBuffer = require '../src/tokenized-buffer'
|
|
|
|
|
|
|
|
describe "TokenIterator", ->
|
|
|
|
it "correctly terminates scopes at the beginning of the line (regression)", ->
|
|
|
|
grammar = atom.grammars.createGrammar('test', {
|
|
|
|
'scopeName': 'text.broken'
|
|
|
|
'name': 'Broken grammar'
|
|
|
|
'patterns': [
|
|
|
|
{
|
|
|
|
'begin': 'start'
|
|
|
|
'end': '(?=end)'
|
|
|
|
'name': 'blue.broken'
|
|
|
|
}
|
|
|
|
{
|
|
|
|
'match': '.'
|
|
|
|
'name': 'yellow.broken'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
buffer = new TextBuffer(text: """
|
|
|
|
start x
|
|
|
|
end x
|
|
|
|
x
|
|
|
|
""")
|
2015-10-03 20:31:30 +03:00
|
|
|
tokenizedBuffer = new TokenizedBuffer({
|
2015-10-06 15:41:43 +03:00
|
|
|
buffer, config: atom.config, grammarRegistry: atom.grammars, packageManager: atom.packages, assert: atom.assert
|
2015-10-03 20:31:30 +03:00
|
|
|
})
|
2015-09-08 19:32:00 +03:00
|
|
|
tokenizedBuffer.setGrammar(grammar)
|
|
|
|
|
2016-10-12 09:50:25 +03:00
|
|
|
tokenIterator = tokenizedBuffer.tokenizedLines[1].getTokenIterator()
|
2015-09-08 19:32:00 +03:00
|
|
|
tokenIterator.next()
|
|
|
|
|
|
|
|
expect(tokenIterator.getBufferStart()).toBe 0
|
|
|
|
expect(tokenIterator.getScopeEnds()).toEqual []
|
|
|
|
expect(tokenIterator.getScopeStarts()).toEqual ['text.broken', 'yellow.broken']
|