Skip to content

Commit f3033a2

Browse files
adamwightmarijnh
authored andcommitted
Send new "updateGutter" signal on gutter resize
Some consumers need to know when the gutter width changes. For example, the MediaWiki Visual Editor maintains a transparent overlay that must always line up with the CodeMirror text area. The gutters can be resized, for example when line numbering is toggled and content grows beyond 1,000 lines. This shifts the text area, and some styles may need to recalculate based on the new value of `display.gutters.offsetWidth`.
1 parent a8f5286 commit f3033a2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/display/update_display.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } fr
55
import { mac, webkit } from "../util/browser.js"
66
import { activeElt, removeChildren, contains } from "../util/dom.js"
77
import { hasHandler, signal } from "../util/event.js"
8+
import { signalLater } from "../util/operation_group.js"
89
import { indexOf } from "../util/misc.js"
910

1011
import { buildLineElement, updateLineForChanges } from "./update_line.js"
@@ -254,6 +255,8 @@ function patchDisplay(cm, updateNumbersFrom, dims) {
254255
export function updateGutterSpace(display) {
255256
let width = display.gutters.offsetWidth
256257
display.sizer.style.marginLeft = width + "px"
258+
// Send an event to consumers responding to changes in gutter width.
259+
signalLater(display, "gutterChanged", display)
257260
}
258261

259262
export function setDocumentHeight(cm, measure) {

0 commit comments

Comments
 (0)