Skip to content

Commit

Permalink
Fix update order bug in viewport tracking
Browse files Browse the repository at this point in the history
FIX: Fix an issue where `viewportLineBlocks` could hold inaccurate
height information when the vertical scaling changed.

Closes codemirror/dev#640
  • Loading branch information
marijnh committed Dec 14, 2021
1 parent 30c9a69 commit 38f0d90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/viewstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class ViewState {
let updateLines = !update.changes.empty || (update.flags & UpdateFlag.Height) ||
viewport.from != this.viewport.from || viewport.to != this.viewport.to
this.viewport = viewport
if (updateLines) this.updateViewportLines()
this.updateForViewport()
if (updateLines) this.updateViewportLines()
if (this.lineGaps.length || this.viewport.to - this.viewport.from > LG.DoubleMargin)
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)))
update.flags |= this.computeVisibleRanges()
Expand Down Expand Up @@ -274,9 +274,9 @@ export class ViewState {
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to)
if (viewportChange) this.viewport = this.getViewport(bias, this.scrollTarget)
this.updateForViewport()
if ((result & UpdateFlag.Height) || viewportChange) this.updateViewportLines()

this.updateForViewport()
if (this.lineGaps.length || this.viewport.to - this.viewport.from > LG.DoubleMargin)
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps))
result |= this.computeVisibleRanges()
Expand Down

0 comments on commit 38f0d90

Please sign in to comment.