From f3033a229971ab0cc59ded104f48303e58923530 Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Thu, 8 Apr 2021 10:07:01 +0200 Subject: [PATCH] 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`. --- src/display/update_display.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/display/update_display.js b/src/display/update_display.js index e6c21a0ad7..83c2540705 100644 --- a/src/display/update_display.js +++ b/src/display/update_display.js @@ -5,6 +5,7 @@ import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } fr import { mac, webkit } from "../util/browser.js" import { activeElt, removeChildren, contains } from "../util/dom.js" import { hasHandler, signal } from "../util/event.js" +import { signalLater } from "../util/operation_group.js" import { indexOf } from "../util/misc.js" import { buildLineElement, updateLineForChanges } from "./update_line.js" @@ -254,6 +255,8 @@ function patchDisplay(cm, updateNumbersFrom, dims) { export function updateGutterSpace(display) { let width = display.gutters.offsetWidth display.sizer.style.marginLeft = width + "px" + // Send an event to consumers responding to changes in gutter width. + signalLater(display, "gutterChanged", display) } export function setDocumentHeight(cm, measure) {