mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Fix some off by one errors in the overdraw calculations
This commit is contained in:
parent
328aa3ba6b
commit
8fba4ff935
@ -478,6 +478,8 @@ fdescribe "Editor", ->
|
||||
describe "when scrolling vertically", ->
|
||||
describe "whes scrolling less than the editor's height", ->
|
||||
it "draws new lines and removes old lines when the last visible line will exceed the last rendered line", ->
|
||||
expect(editor.visibleLines.find('.line').length).toBe 8
|
||||
|
||||
editor.scrollTop(editor.lineHeight * 1.5)
|
||||
expect(editor.visibleLines.find('.line').length).toBe 8
|
||||
expect(editor.visibleLines.find('.line:first').text()).toBe buffer.lineForRow(0)
|
||||
@ -566,7 +568,7 @@ fdescribe "Editor", ->
|
||||
spyOn(editor, "scrollTo")
|
||||
|
||||
describe "when the change the precedes the first rendered row", ->
|
||||
fffit "inserts and removes rendered lines to account for upstream change", ->
|
||||
it "inserts and removes rendered lines to account for upstream change", ->
|
||||
console.log "-------------------"
|
||||
editor.scrollToBottom()
|
||||
expect(editor.visibleLines.find(".line:first").text()).toBe buffer.lineForRow(6)
|
||||
|
@ -311,20 +311,20 @@ class Editor extends View
|
||||
console.log "Rendering lines %d-%d", renderFrom, renderTo
|
||||
|
||||
if firstVisibleScreenRow < @firstRenderedScreenRow
|
||||
@removeLineElements(Math.max(@firstRenderedScreenRow, renderTo), @lastRenderedScreenRow)
|
||||
@removeLineElements(Math.max(@firstRenderedScreenRow, renderTo + 1), @lastRenderedScreenRow)
|
||||
@lastRenderedScreenRow = renderTo
|
||||
@firstRenderedScreenRow = renderFrom
|
||||
newLines = @buildLineElements(renderFrom, Math.min(@firstRenderedScreenRow, renderTo))
|
||||
newLines = @buildLineElements(renderFrom, Math.min(@firstRenderedScreenRow - 1, renderTo))
|
||||
@insertLineElements(renderFrom, newLines)
|
||||
@firstRenderedScreenRow = renderFrom
|
||||
adjustPadding = true
|
||||
|
||||
if lastVisibleScreenRow > @lastRenderedScreenRow
|
||||
@removeLineElements(@firstRenderedScreenRow, Math.min(@lastRenderedScreenRow, renderFrom))
|
||||
@removeLineElements(@firstRenderedScreenRow, Math.min(@lastRenderedScreenRow, renderFrom - 1)) if @firstRenderedScreenRow >= 0
|
||||
@firstRenderedScreenRow = renderFrom
|
||||
@lastRenderedScreenRow = renderTo
|
||||
startRowOfNewLines = Math.max(@lastRenderedScreenRow, renderFrom)
|
||||
startRowOfNewLines = Math.max(@lastRenderedScreenRow + 1, renderFrom)
|
||||
newLines = @buildLineElements(startRowOfNewLines, renderTo)
|
||||
@insertLineElements(startRowOfNewLines, newLines)
|
||||
@lastRenderedScreenRow = renderTo
|
||||
adjustPadding = true
|
||||
|
||||
if adjustPadding
|
||||
@ -548,9 +548,12 @@ class Editor extends View
|
||||
@spliceLineElements(startRow, endRow - startRow + 1, lineElements)
|
||||
|
||||
removeLineElements: (startRow, endRow) ->
|
||||
console.log "removeLineElements", startRow, endRow
|
||||
@spliceLineElements(startRow, endRow - startRow + 1)
|
||||
|
||||
spliceLineElements: (startScreenRow, rowCount, lineElements) ->
|
||||
throw new Error("Splicing at a negative start row: #{startScreenRow}") if startScreenRow < 0
|
||||
|
||||
if startScreenRow < @firstRenderedScreenRow
|
||||
startRow = 0
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user