Skip to content

Commit

Permalink
🔥 Remove screen delta guards
Browse files Browse the repository at this point in the history
Screen delta represents the differences in number of lines between the
version before the change and the version after the change.
Changes that comes from the TextEditor always have a screen delta. The
only ones that doesn’t comes from the decoration management. And in
fact, manipulating decorations doesn’t changes the screen lines so
their screen delta is always 0.
  • Loading branch information
abe33 committed Mar 11, 2015
1 parent b6067d5 commit 094f77a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 0 additions & 3 deletions lib/mixins/canvas-drawer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,6 @@ class CanvasDrawer extends Mixin
for change in @pendingChanges
newIntactRanges = []
for range in intactRanges
if isNaN(change.screenDelta)
change.screenDelta = change.end - change.start

if change.end < range.start and change.screenDelta != 0
newIntactRanges.push(
start: range.start + change.screenDelta
Expand Down
8 changes: 3 additions & 5 deletions lib/mixins/decoration-management.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class DecorationManagement extends Mixin

[start, end] = [end, start] if start.row > end.row

@emitRangeChanges({start, end, screenDelta: end - start})
@emitRangeChanges({start, end})

decoration = new Decoration(marker, this, decorationParams)
@decorationsByMarkerId[marker.id] ?= []
Expand Down Expand Up @@ -229,14 +229,12 @@ class DecorationManagement extends Mixin
# Internal: Emits a change for the specified range.
#
# range - The `Range` to emits changes for.
emitRangeChanges: (range) ->
emitRangeChanges: (range, screenDelta) ->
startScreenRow = range.start.row
endScreenRow = range.end.row
lastRenderedScreenRow = @getLastVisibleScreenRow()
firstRenderedScreenRow = @getFirstVisibleScreenRow()
screenDelta = (lastRenderedScreenRow - firstRenderedScreenRow) - (endScreenRow - startScreenRow)

screenDelta = 0 if isNaN(screenDelta)
screenDelta ?= (lastRenderedScreenRow - firstRenderedScreenRow) - (endScreenRow - startScreenRow)

changeEvent =
start: startScreenRow
Expand Down

0 comments on commit 094f77a

Please sign in to comment.