Fix gutter rendering when there are folds

Fixes #1059
This commit is contained in:
Ben Ogle 2013-10-31 12:32:27 -07:00
parent d14e5a6992
commit d150170e5b
2 changed files with 25 additions and 6 deletions

View File

@ -1766,6 +1766,14 @@ describe "Editor", ->
expect(editor.gutter.find('.line-number:first').intValue()).toBe 2
expect(editor.gutter.find('.line-number:last').intValue()).toBe 11
it "re-renders the correct line number range when there are folds", ->
editor.activeEditSession.foldBufferRow(1)
expect(editor.gutter.find('.line-number-1')).toHaveClass 'fold'
buffer.insert([0, 0], '\n')
expect(editor.gutter.find('.line-number-2')).toHaveClass 'fold'
describe "when wrapping is on", ->
it "renders a • instead of line number for wrapped portions of lines", ->
editSession.setSoftWrap(true)

View File

@ -141,12 +141,23 @@ class Gutter extends View
updateAllLines = not (startScreenRow? and endScreenRow?)
updateAllLines |= endScreenRow <= @firstScreenRow or startScreenRow >= @lastScreenRow
for change in changes
# When there is a change to the bufferRow -> screenRow map (i.e. a fold),
# then rerender everything.
if (change.screenDelta or change.bufferDelta) and change.screenDelta != change.bufferDelta
updateAllLines = true
break
unless updateAllLines
minChangeStartScreenRow = null
for change in changes
# When there is a change to the bufferRow -> screenRow map (i.e. a fold),
# then rerender everything.
if (change.screenDelta or change.bufferDelta) and change.screenDelta != change.bufferDelta
updateAllLines = true
break
else if change.screenDelta or change.bufferDelta
minChangeStartScreenRow = Math.min(change.start, minChangeStartScreenRow)
if minChangeStartScreenRow? and not updateAllLines
# Need to rerender when changes are before a fold
for screenRow in [minChangeStartScreenRow...endScreenRow]
if @getEditor().isFoldedAtScreenRow(screenRow)
updateAllLines = true
break
if updateAllLines
@lineNumbers[0].innerHTML = @buildLineElementsHtml(startScreenRow, endScreenRow)