Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 0a2d822

Browse files
committed
Properly include outerDecorations in height map structure
FIX: Fix a bug that caused `EditorView.outerDecorations` to not affect the content height map. Closes codemirror/dev#1658
1 parent 1524fb5 commit 0a2d822

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/viewstate.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Text, EditorState, ChangeSet, ChangeDesc, RangeSet, EditorSelection} fro
22
import {Rect, isScrolledToBottom, getScale} from "./dom"
33
import {HeightMap, HeightOracle, BlockInfo, MeasuredHeights, QueryType, heightRelevantDecoChanges,
44
clearHeightChangeFlag, heightChangeFlag} from "./heightmap"
5-
import {decorations, ViewUpdate, UpdateFlag, ChangedRange, ScrollTarget, nativeSelectionHidden,
5+
import {decorations, outerDecorations, ViewUpdate, UpdateFlag, ChangedRange, ScrollTarget, nativeSelectionHidden,
66
contentAttributes} from "./extension"
77
import {WidgetType, Decoration, DecorationSet, BlockType} from "./decoration"
88
import {EditorView} from "./editorview"
@@ -172,7 +172,7 @@ export class ViewState {
172172
constructor(public state: EditorState) {
173173
let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping")
174174
this.heightOracle = new HeightOracle(guessWrapping)
175-
this.stateDeco = state.facet(decorations).filter(d => typeof d != "function") as readonly DecorationSet[]
175+
this.stateDeco = staticDeco(state)
176176
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc),
177177
[new ChangedRange(0, 0, 0, state.doc.length)])
178178
for (let i = 0; i < 2; i++) {
@@ -216,9 +216,9 @@ export class ViewState {
216216
update(update: ViewUpdate, scrollTarget: ScrollTarget | null = null) {
217217
this.state = update.state
218218
let prevDeco = this.stateDeco
219-
this.stateDeco = this.state.facet(decorations).filter(d => typeof d != "function") as readonly DecorationSet[]
219+
this.stateDeco = staticDeco(this.state)
220220
let contentChanges = update.changedRanges
221-
221+
222222
let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(
223223
prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)))
224224
let prevHeight = this.heightMap.height
@@ -664,6 +664,13 @@ const IdScaler: YScaler = {
664664
eq(other: YScaler) { return other == this }
665665
}
666666

667+
function staticDeco(state: EditorState) {
668+
let deco = state.facet(decorations).filter(d => typeof d != "function") as DecorationSet[]
669+
let outer = state.facet(outerDecorations).filter(d => typeof d != "function") as DecorationSet[]
670+
if (outer.length) deco.push(RangeSet.join(outer))
671+
return deco
672+
}
673+
667674
// When the height is too big (> VP.MaxDOMHeight), scale down the
668675
// regions outside the viewports so that the total height is
669676
// VP.MaxDOMHeight.

0 commit comments

Comments
 (0)