mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
If no non-negative integer exists between an open and close tag code, we still need to report a boundary there, since close tags always have to come first at any given iterator position. :pear:ed with @as-cii
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/** @babel */
|
|
|
|
import TokenizedBufferIterator from '../src/tokenized-buffer-iterator'
|
|
import {Point} from 'text-buffer'
|
|
|
|
describe('TokenizedBufferIterator', () => {
|
|
it('reports two boundaries at the same position when tags close, open, then close again without a non-negative integer separating them (regression)', () => {
|
|
const tokenizedBuffer = {
|
|
tokenizedLineForRow () {
|
|
return {
|
|
tags: [-1, -2, -1, -2],
|
|
text: '',
|
|
openScopes: []
|
|
}
|
|
}
|
|
}
|
|
|
|
const grammarRegistry = {
|
|
scopeForId () {
|
|
return 'foo'
|
|
}
|
|
}
|
|
|
|
const iterator = new TokenizedBufferIterator(tokenizedBuffer, grammarRegistry)
|
|
|
|
iterator.seek(Point(0, 0))
|
|
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
|
expect(iterator.getCloseTags()).toEqual([])
|
|
expect(iterator.getOpenTags()).toEqual(['foo'])
|
|
|
|
iterator.moveToSuccessor()
|
|
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
|
expect(iterator.getCloseTags()).toEqual(['foo'])
|
|
expect(iterator.getOpenTags()).toEqual(['foo'])
|
|
|
|
iterator.moveToSuccessor()
|
|
expect(iterator.getCloseTags()).toEqual(['foo'])
|
|
expect(iterator.getOpenTags()).toEqual([])
|
|
})
|
|
})
|