Skip to content

Commit 441d528

Browse files
committed
Revert "Support a persistent option for widgets"
This reverts commit 522bacc. The feature, as designed there, cannot really work due to the way range sets optimize mapping of deleted chunks. See https://discuss.codemirror.net/t/mapmode-simple-for-block-widget-decorations/9040/3
1 parent 522bacc commit 441d528

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/decoration.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ interface WidgetDecorationSpec {
6666
/// [`requestMeasure`](#view.EditorView.requestMeasure), so that the
6767
/// editor can update its information about its vertical layout.
6868
block?: boolean
69-
/// By default, widgets get removed, during mapping, when the
70-
/// content around them is deleted. Set this to true to make a
71-
/// widget survive such changes.
72-
persistent?: boolean
7369
/// Other properties are allowed.
7470
[other: string]: any
7571
}
@@ -243,7 +239,7 @@ export abstract class Decoration extends RangeValue {
243239
side += (block && !spec.inlineOrder)
244240
? (side > 0 ? Side.BlockAfter : Side.BlockBefore)
245241
: (side > 0 ? Side.InlineAfter : Side.InlineBefore)
246-
return new PointDecoration(spec, side, side, block, !!spec.persistent, spec.widget || null, false)
242+
return new PointDecoration(spec, side, side, block, spec.widget || null, false)
247243
}
248244

249245
/// Create a replace decoration which replaces the given range with
@@ -258,7 +254,7 @@ export abstract class Decoration extends RangeValue {
258254
startSide = (start ? (block ? Side.BlockIncStart : Side.InlineIncStart) : Side.NonIncStart) - 1
259255
endSide = (end ? (block ? Side.BlockIncEnd : Side.InlineIncEnd) : Side.NonIncEnd) + 1
260256
}
261-
return new PointDecoration(spec, startSide, endSide, block, false, spec.widget || null, true)
257+
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true)
262258
}
263259

264260
/// Create a line decoration, which can add DOM attributes to the
@@ -336,14 +332,10 @@ export class PointDecoration extends Decoration {
336332
constructor(spec: any,
337333
startSide: number, endSide: number,
338334
public block: boolean,
339-
persistent: boolean,
340335
widget: WidgetType | null,
341336
readonly isReplace: boolean) {
342337
super(startSide, endSide, widget, spec)
343-
this.mapMode = persistent ? MapMode.Simple
344-
: !block ? MapMode.TrackDel
345-
: startSide <= 0 ? MapMode.TrackBefore
346-
: MapMode.TrackAfter
338+
this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter
347339
}
348340

349341
// Only relevant when this.block == true

0 commit comments

Comments
 (0)