Skip to content

Commit

Permalink
Update demo gif. Fix error when there was no last diff chunk (related…
Browse files Browse the repository at this point in the history
… to #58).
  • Loading branch information
mupchrch committed Jun 2, 2016
1 parent 914566a commit bbce6b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions lib/split-diff.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,16 @@ module.exports = SplitDiff =
@footerView?.setNumDifferences(@linkedDiffChunks.length)

# make the last chunk equal size on both screens so the editors retain sync scroll #58
lastDiffChunk = @linkedDiffChunks[@linkedDiffChunks.length-1]
oldChunkRange = lastDiffChunk.oldLineEnd - lastDiffChunk.oldLineStart
newChunkRange = lastDiffChunk.newLineEnd - lastDiffChunk.newLineStart
if oldChunkRange > newChunkRange
# make the offset as large as needed to make the chunk the same size in both editors
computedDiff.newLineOffsets[lastDiffChunk.newLineStart + newChunkRange] = oldChunkRange - newChunkRange
else if newChunkRange > oldChunkRange
# make the offset as large as needed to make the chunk the same size in both editors
computedDiff.oldLineOffsets[lastDiffChunk.oldLineStart + oldChunkRange] = newChunkRange - oldChunkRange
if @linkedDiffChunks.length > 0
lastDiffChunk = @linkedDiffChunks[@linkedDiffChunks.length-1]
oldChunkRange = lastDiffChunk.oldLineEnd - lastDiffChunk.oldLineStart
newChunkRange = lastDiffChunk.newLineEnd - lastDiffChunk.newLineStart
if oldChunkRange > newChunkRange
# make the offset as large as needed to make the chunk the same size in both editors
computedDiff.newLineOffsets[lastDiffChunk.newLineStart + newChunkRange] = oldChunkRange - newChunkRange
else if newChunkRange > oldChunkRange
# make the offset as large as needed to make the chunk the same size in both editors
computedDiff.oldLineOffsets[lastDiffChunk.oldLineStart + oldChunkRange] = newChunkRange - oldChunkRange

@_clearDiff()
@_displayDiff(editors, computedDiff)
Expand Down

0 comments on commit bbce6b2

Please sign in to comment.