mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge branch 'master' of github.com:github/atom
This commit is contained in:
@@ -90,6 +90,30 @@ describe "Renderer", ->
|
||||
expect(event.oldRange).toEqual([[8, 0], [10, 20]])
|
||||
expect(event.newRange).toEqual([[8, 0], [10, 20]])
|
||||
|
||||
describe "when a fold ends on the penultimate screen line of a wrapped buffer line", ->
|
||||
beforeEach ->
|
||||
renderer.setMaxLineLength(36)
|
||||
changeHandler.reset()
|
||||
|
||||
it "inserts the placeholder in the correct location and fires a change event", ->
|
||||
fold = renderer.createFold([[5, 0], [6, 29]])
|
||||
expect(renderer.lineForRow(6).text).toBe " while(items.length > 0) {"
|
||||
expect(renderer.lineForRow(7).text).toBe "...push(current) : "
|
||||
expect(renderer.lineForRow(8).text).toBe "right.push(current);"
|
||||
|
||||
expect(changeHandler).toHaveBeenCalled()
|
||||
[[event]]= changeHandler.argsForCall
|
||||
expect(event.oldRange).toEqual([[7, 0], [10, 20]])
|
||||
expect(event.newRange).toEqual([[7, 0], [8, 20]])
|
||||
|
||||
changeHandler.reset()
|
||||
fold.destroy()
|
||||
|
||||
expect(changeHandler).toHaveBeenCalled()
|
||||
[[event]]= changeHandler.argsForCall
|
||||
expect(event.oldRange).toEqual([[7, 0], [8, 20]])
|
||||
expect(event.newRange).toEqual([[7, 0], [10, 20]])
|
||||
|
||||
describe "when there is a fold placeholder straddling the max length boundary", ->
|
||||
it "wraps the line before the fold placeholder", ->
|
||||
renderer.createFold([[3, 49], [6, 1]])
|
||||
|
||||
@@ -137,34 +137,35 @@ class Renderer
|
||||
buildLineForBufferRow: (bufferRow) ->
|
||||
@buildLinesForBufferRows(bufferRow, bufferRow)
|
||||
|
||||
buildLinesForBufferRows: (startRow, endRow) ->
|
||||
recursiveBuildLinesForBufferRows = (startRow, endRow, startColumn, currentScreenLineLength=0) =>
|
||||
return [] if startRow > endRow and not startColumn?
|
||||
buildLinesForBufferRows: (startBufferRow, endBufferRow) ->
|
||||
recursiveBuildLinesForBufferRows = (startBufferRow, endBufferRow, startBufferColumn, currentScreenLineLength=0) =>
|
||||
return [] if startBufferRow > endBufferRow and not startBufferColumn?
|
||||
|
||||
startColumn ?= 0
|
||||
line = @highlighter.lineForRow(startRow).splitAt(startColumn)[1]
|
||||
startBufferColumn ?= 0
|
||||
line = @highlighter.lineForRow(startBufferRow).splitAt(startBufferColumn)[1]
|
||||
|
||||
wrapColumn = @findWrapColumn(line.text, @maxLineLength - currentScreenLineLength)
|
||||
wrapScreenColumn = @findWrapColumn(line.text, @maxLineLength - currentScreenLineLength)
|
||||
|
||||
for fold in @foldsForBufferRow(startRow)
|
||||
if fold.start.column >= startColumn
|
||||
if (fold.start.column - startColumn) > wrapColumn - foldPlaceholderLength
|
||||
wrapColumn = Math.min(wrapColumn, fold.start.column - startColumn)
|
||||
for fold in @foldsForBufferRow(startBufferRow)
|
||||
if fold.start.column >= startBufferColumn
|
||||
foldStartSceenColumn = fold.start.column - startBufferColumn
|
||||
if (foldStartSceenColumn) > wrapScreenColumn - foldPlaceholderLength
|
||||
wrapScreenColumn = Math.min(wrapScreenColumn, foldStartSceenColumn)
|
||||
break
|
||||
prefix = line.splitAt(fold.start.column - startColumn)[0]
|
||||
prefix = line.splitAt(foldStartSceenColumn)[0]
|
||||
placeholder = @buildFoldPlaceholder(fold)
|
||||
currentScreenLineLength = currentScreenLineLength + (prefix?.text.length ? 0) + foldPlaceholderLength
|
||||
suffix = recursiveBuildLinesForBufferRows(fold.end.row, endRow, fold.end.column, currentScreenLineLength)
|
||||
suffix = recursiveBuildLinesForBufferRows(fold.end.row, endBufferRow, fold.end.column, currentScreenLineLength)
|
||||
return _.compact _.flatten [prefix, placeholder, suffix]
|
||||
|
||||
if wrapColumn?
|
||||
line = line.splitAt(wrapColumn)[0]
|
||||
if wrapScreenColumn?
|
||||
line = line.splitAt(wrapScreenColumn)[0]
|
||||
line.screenDelta = new Point(1, 0)
|
||||
[line].concat recursiveBuildLinesForBufferRows(startRow, endRow, startColumn + wrapColumn)
|
||||
[line].concat recursiveBuildLinesForBufferRows(startBufferRow, endBufferRow, startBufferColumn + wrapScreenColumn)
|
||||
else
|
||||
[line].concat recursiveBuildLinesForBufferRows(startRow + 1, endRow)
|
||||
[line].concat recursiveBuildLinesForBufferRows(startBufferRow + 1, endBufferRow)
|
||||
|
||||
recursiveBuildLinesForBufferRows(@foldStartRowForBufferRow(startRow), endRow)
|
||||
recursiveBuildLinesForBufferRows(@foldStartRowForBufferRow(startBufferRow), endBufferRow)
|
||||
|
||||
foldStartRowForBufferRow: (bufferRow) ->
|
||||
@bufferRowForScreenRow(@screenRowForBufferRow(bufferRow))
|
||||
@@ -212,8 +213,7 @@ class Renderer
|
||||
|
||||
expandBufferRangeToLineEnds: (bufferRange) ->
|
||||
{ start, end } = bufferRange
|
||||
endColumn = @lineMap.lineForBufferRow(end.row)?.text.length ? 0
|
||||
new Range([start.row, 0], [end.row, endColumn])
|
||||
new Range([start.row, 0], [end.row, Infinity])
|
||||
|
||||
rangeForAllLines: ->
|
||||
new Range([0, 0], @clipScreenPosition([Infinity, Infinity]))
|
||||
|
||||
Reference in New Issue
Block a user