MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / alignHorizontally

Function alignHorizontally

lib/web/CodeMirror/src/display/line_numbers.js:9–27  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

7// Re-align line numbers and gutter marks to compensate for
8// horizontal scrolling.
9export function alignHorizontally(cm) {
10 let display = cm.display, view = display.view
11 if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return
12 let comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft
13 let gutterW = display.gutters.offsetWidth, left = comp + "px"
14 for (let i = 0; i < view.length; i++) if (!view[i].hidden) {
15 if (cm.options.fixedGutter) {
16 if (view[i].gutter)
17 view[i].gutter.style.left = left
18 if (view[i].gutterBackground)
19 view[i].gutterBackground.style.left = left
20 }
21 let align = view[i].alignable
22 if (align) for (let j = 0; j < align.length; j++)
23 align[j].style.left = left
24 }
25 if (cm.options.fixedGutter)
26 display.gutters.style.left = (comp + gutterW) + "px"
27}
28
29// Used to ensure that the line number gutter is still the right
30// size for the current document size. Returns true when an update

Callers 2

setScrollLeftFunction · 0.90
updateGuttersFunction · 0.90

Calls 1

compensateForHScrollFunction · 0.90

Tested by

no test coverage detected