Skip to content

Commit

Permalink
Decide on line gaps per textual line, not per line block
Browse files Browse the repository at this point in the history
FIX: Fix an issue where long lines broken up by block widgets were sometimes
only partially rendered.

Closes codemirror/dev#1387
  • Loading branch information
marijnh committed Jun 5, 2024
1 parent b16b0f2 commit df421a1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/viewstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Rect, isScrolledToBottom, getScale} from "./dom"
import {HeightMap, HeightOracle, BlockInfo, MeasuredHeights, QueryType, heightRelevantDecoChanges} from "./heightmap"
import {decorations, ViewUpdate, UpdateFlag, ChangedRange, ScrollTarget, nativeSelectionHidden,
contentAttributes} from "./extension"
import {WidgetType, Decoration, DecorationSet} from "./decoration"
import {WidgetType, Decoration, DecorationSet, BlockType} from "./decoration"
import {EditorView} from "./editorview"
import {Direction} from "./bidi"

Expand Down Expand Up @@ -460,10 +460,10 @@ export class ViewState {
gaps.push(gap)
}

for (let line of this.viewportLines) {
if (line.length < doubleMargin) continue
let checkLine = (line: BlockInfo) => {
if (line.length < doubleMargin || line.type != BlockType.Text) return
let structure = lineStructure(line.from, line.to, this.stateDeco)
if (structure.total < doubleMargin) continue
if (structure.total < doubleMargin) return
let target = this.scrollTarget ? this.scrollTarget.range.head : null
let viewFrom, viewTo
if (wrapping) {
Expand Down Expand Up @@ -500,6 +500,11 @@ export class ViewState {
if (viewFrom > line.from) addGap(line.from, viewFrom, line, structure)
if (viewTo < line.to) addGap(viewTo, line.to, line, structure)
}

for (let line of this.viewportLines) {
if (Array.isArray(line.type)) line.type.forEach(checkLine)
else checkLine(line)
}
return gaps
}

Expand Down

0 comments on commit df421a1

Please sign in to comment.