Adjust multiple mappings if needed when applying screen deltas

If there are multiple mappings following the start row of the delta
that span fewer screen rows than the delta, we collapse mappings to 0
screen rows until we have removed the number of rows specified by the
delta.

Expanding positive deltas expands the first mapping following the
start row as it did previously.
This commit is contained in:
Nathan Sobo
2013-05-08 14:18:51 -06:00
parent c6ff7e8934
commit c17d6ba487
2 changed files with 35 additions and 3 deletions

View File

@@ -50,9 +50,18 @@ class RowMap
{ mapping } = @traverseToBufferRow(startBufferRow)
mapping?.bufferRows += delta
applyScreenDelta: (startBufferRow, delta) ->
{ mapping } = @traverseToScreenRow(startBufferRow)
mapping?.screenRows += delta
applyScreenDelta: (startScreenRow, delta) ->
{ index } = @traverseToScreenRow(startScreenRow)
until delta == 0
{ bufferRows, screenRows } = @mappings[index]
screenRows += delta
if screenRows < 0
delta = screenRows
screenRows = 0
else
delta = 0
@mappings[index] = { bufferRows, screenRows }
index++
traverseToBufferRow: (targetBufferRow) ->
bufferRow = 0