mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Fix remaining test failures in core
This commit is contained in:
parent
bc34344d90
commit
c541d3941c
@ -5418,8 +5418,8 @@ describe "TextEditor", ->
|
||||
|
||||
tokens = editor.tokensForScreenRow(0)
|
||||
expect(tokens).toEqual [
|
||||
{text: '//', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--punctuation.syntax--definition.syntax--comment.syntax--js']},
|
||||
{text: ' http://github.com', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']}
|
||||
{text: '//', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--punctuation syntax--definition syntax--comment syntax--js']},
|
||||
{text: ' http://github.com', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']}
|
||||
]
|
||||
|
||||
waitsForPromise ->
|
||||
@ -5428,9 +5428,9 @@ describe "TextEditor", ->
|
||||
runs ->
|
||||
tokens = editor.tokensForScreenRow(0)
|
||||
expect(tokens).toEqual [
|
||||
{text: '//', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--punctuation.syntax--definition.syntax--comment.syntax--js']},
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']}
|
||||
{text: 'http://github.com', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--markup.syntax--underline.syntax--link.syntax--http.syntax--hyperlink']}
|
||||
{text: '//', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--punctuation syntax--definition syntax--comment syntax--js']},
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']}
|
||||
{text: 'http://github.com', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--markup syntax--underline syntax--link syntax--http syntax--hyperlink']}
|
||||
]
|
||||
|
||||
describe "when the grammar is updated", ->
|
||||
@ -5443,8 +5443,8 @@ describe "TextEditor", ->
|
||||
|
||||
tokens = editor.tokensForScreenRow(0)
|
||||
expect(tokens).toEqual [
|
||||
{text: '//', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--punctuation.syntax--definition.syntax--comment.syntax--js']},
|
||||
{text: ' SELECT * FROM OCTOCATS', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']}
|
||||
{text: '//', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--punctuation syntax--definition syntax--comment syntax--js']},
|
||||
{text: ' SELECT * FROM OCTOCATS', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']}
|
||||
]
|
||||
|
||||
waitsForPromise ->
|
||||
@ -5453,8 +5453,8 @@ describe "TextEditor", ->
|
||||
runs ->
|
||||
tokens = editor.tokensForScreenRow(0)
|
||||
expect(tokens).toEqual [
|
||||
{text: '//', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--punctuation.syntax--definition.syntax--comment.syntax--js']},
|
||||
{text: ' SELECT * FROM OCTOCATS', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']}
|
||||
{text: '//', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--punctuation syntax--definition syntax--comment syntax--js']},
|
||||
{text: ' SELECT * FROM OCTOCATS', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']}
|
||||
]
|
||||
|
||||
waitsForPromise ->
|
||||
@ -5463,14 +5463,14 @@ describe "TextEditor", ->
|
||||
runs ->
|
||||
tokens = editor.tokensForScreenRow(0)
|
||||
expect(tokens).toEqual [
|
||||
{text: '//', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--punctuation.syntax--definition.syntax--comment.syntax--js']},
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']},
|
||||
{text: 'SELECT', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--keyword.syntax--other.syntax--DML.syntax--sql']},
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']},
|
||||
{text: '*', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--keyword.syntax--operator.syntax--star.syntax--sql']},
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']},
|
||||
{text: 'FROM', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js', 'syntax--keyword.syntax--other.syntax--DML.syntax--sql']},
|
||||
{text: ' OCTOCATS', scopes: ['syntax--source.syntax--js', 'syntax--comment.syntax--line.syntax--double-slash.syntax--js']}
|
||||
{text: '//', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--punctuation syntax--definition syntax--comment syntax--js']},
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']},
|
||||
{text: 'SELECT', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--keyword syntax--other syntax--DML syntax--sql']},
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']},
|
||||
{text: '*', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--keyword syntax--operator syntax--star syntax--sql']},
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']},
|
||||
{text: 'FROM', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js', 'syntax--keyword syntax--other syntax--DML syntax--sql']},
|
||||
{text: ' OCTOCATS', scopes: ['syntax--source syntax--js', 'syntax--comment syntax--line syntax--double-slash syntax--js']}
|
||||
]
|
||||
|
||||
describe ".normalizeTabsInBufferRange()", ->
|
||||
@ -5853,20 +5853,20 @@ describe "TextEditor", ->
|
||||
|
||||
editor.update({showIndentGuide: false})
|
||||
expect(editor.tokensForScreenRow(0)).toEqual [
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'leading-whitespace']},
|
||||
{text: 'foo', scopes: ['syntax--source.syntax--js']}
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'leading-whitespace']},
|
||||
{text: 'foo', scopes: ['syntax--source syntax--js']}
|
||||
]
|
||||
|
||||
editor.update({showIndentGuide: true})
|
||||
expect(editor.tokensForScreenRow(0)).toEqual [
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'leading-whitespace indent-guide']},
|
||||
{text: 'foo', scopes: ['syntax--source.syntax--js']}
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'leading-whitespace indent-guide']},
|
||||
{text: 'foo', scopes: ['syntax--source syntax--js']}
|
||||
]
|
||||
|
||||
editor.setMini(true)
|
||||
expect(editor.tokensForScreenRow(0)).toEqual [
|
||||
{text: ' ', scopes: ['syntax--source.syntax--js', 'leading-whitespace']},
|
||||
{text: 'foo', scopes: ['syntax--source.syntax--js']}
|
||||
{text: ' ', scopes: ['syntax--source syntax--js', 'leading-whitespace']},
|
||||
{text: 'foo', scopes: ['syntax--source syntax--js']}
|
||||
]
|
||||
|
||||
describe "when the editor is constructed with the grammar option set", ->
|
||||
|
@ -25,40 +25,40 @@ describe('TokenizedBufferIterator', () => {
|
||||
expect(iterator.seek(Point(0, 0))).toEqual([])
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([257])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getCloseScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([257])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
expect(iterator.seek(Point(0, 1))).toEqual([5])
|
||||
expect(iterator.seek(Point(0, 1))).toEqual([261])
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([3, 5])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([5])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([259, 261])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([261])
|
||||
|
||||
expect(iterator.seek(Point(0, 3))).toEqual([5])
|
||||
expect(iterator.seek(Point(0, 3))).toEqual([261])
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([3, 5])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([5])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([259, 261])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([261])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 7))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([5])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([261])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 7))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([259])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
@ -66,14 +66,14 @@ describe('TokenizedBufferIterator', () => {
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
|
||||
expect(iterator.seek(Point(0, 5))).toEqual([5])
|
||||
expect(iterator.seek(Point(0, 5))).toEqual([261])
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 7))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([5])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([261])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 7))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([259])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
})
|
||||
})
|
||||
@ -95,15 +95,15 @@ describe('TokenizedBufferIterator', () => {
|
||||
iterator.seek(Point(0, 0))
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([257])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([1])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([257])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([257])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getCloseScopeIds()).toEqual([1])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([257])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
})
|
||||
|
||||
@ -137,26 +137,26 @@ describe('TokenizedBufferIterator', () => {
|
||||
iterator.seek(Point(0, 0))
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([257])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([257])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([259])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(0, 3))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([3])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([259])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(1, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([1])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([257])
|
||||
|
||||
iterator.moveToSuccessor()
|
||||
expect(iterator.getPosition()).toEqual(Point(2, 0))
|
||||
expect(iterator.getCloseScopeIds()).toEqual([1])
|
||||
expect(iterator.getCloseScopeIds()).toEqual([257])
|
||||
expect(iterator.getOpenScopeIds()).toEqual([])
|
||||
})
|
||||
})
|
||||
|
@ -1017,18 +1017,18 @@ class TextEditor extends Model
|
||||
tokens = []
|
||||
lineTextIndex = 0
|
||||
currentTokenScopes = []
|
||||
{lineText, tagCodes} = @screenLineForScreenRow(screenRow)
|
||||
for tagCode in tagCodes
|
||||
if @displayLayer.isOpenTagCode(tagCode)
|
||||
currentTokenScopes.push(@displayLayer.tagForCode(tagCode))
|
||||
else if @displayLayer.isCloseTagCode(tagCode)
|
||||
{lineText, tags} = @screenLineForScreenRow(screenRow)
|
||||
for tag in tags
|
||||
if @displayLayer.isOpenTag(tag)
|
||||
currentTokenScopes.push(@displayLayer.classNameForTag(tag))
|
||||
else if @displayLayer.isCloseTag(tag)
|
||||
currentTokenScopes.pop()
|
||||
else
|
||||
tokens.push({
|
||||
text: lineText.substr(lineTextIndex, tagCode)
|
||||
text: lineText.substr(lineTextIndex, tag)
|
||||
scopes: currentTokenScopes.slice()
|
||||
})
|
||||
lineTextIndex += tagCode
|
||||
lineTextIndex += tag
|
||||
tokens
|
||||
|
||||
screenLineForScreenRow: (screenRow) ->
|
||||
|
Loading…
Reference in New Issue
Block a user