Merge pull request #8334 from atom/ns-fix-wrap-scopes

Process closing scopes at wrap boundaries
This commit is contained in:
Nathan Sobo
2015-08-11 14:23:25 -06:00
2 changed files with 11 additions and 2 deletions

View File

@@ -112,6 +112,13 @@ describe "DisplayBuffer", ->
expect(displayBuffer.tokenizedLineForScreenRow(2).text).toBe 'uvwxyz'
expect(displayBuffer.tokenizedLineForScreenRow(2).bufferDelta).toBe 'uvwxyz'.length
it "closes all scopes at the wrap boundary", ->
displayBuffer.setEditorWidthInChars(10)
buffer.setText("`aaa${1+2}aaa`")
iterator = displayBuffer.tokenizedLineForScreenRow(1).getTokenIterator()
scopes = iterator.getScopes()
expect(scopes[scopes.length - 1]).not.toBe 'punctuation.section.embedded.js'
describe "when there is a whitespace character at the max length boundary", ->
it "wraps the line at the first non-whitespace character following the boundary", ->
expect(displayBuffer.tokenizedLineForScreenRow(3).text).toBe ' var pivot = items.shift(), current, left = [], '

View File

@@ -387,15 +387,17 @@ class TokenizedLine
rightSpecialTokens[rightTags.length] = specialToken
rightTags.push(tag)
# tag represents the start or end of a scop
# tag represents the start of a scope
else if (tag % 2) is -1
if screenColumn < column
leftTags.push(tag)
rightOpenScopes.push(tag)
else
rightTags.push(tag)
# tag represents the end of a scope
else
if screenColumn < column
if screenColumn <= column
leftTags.push(tag)
rightOpenScopes.pop()
else