Skip to content

Commit

Permalink
Send new "updateGutter" signal on gutter resize
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
adamwight authored and marijnh committed Apr 13, 2021
1 parent a8f5286 commit f3033a2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/display/update_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f3033a2

Please sign in to comment.