Commit 69ea40c
committed
fix(diff): monkey-patch Monaco's combined-overview-ruler width 30 → 8 px
The previous "unified column on the modified pane" approach worked
mechanically but only showed marks from the modified side — a per-side
overview ruler is structurally incapable of rendering an AGGREGATED
(original + modified) heatmap. So we're going back to Monaco's combined
diff overview ruler (renderOverviewRuler: true) but solving the width
problem properly.
Research (see commit history + agent thread): In Monaco 0.43.x the
combined ruler's width is hardcoded:
esm/vs/editor/browser/widget/diffEditorWidget.js:1125
DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH = 30
It's a static class field, not an editor option. There's no theme key,
no CSS variable, no constructor parameter for it. BUT Monaco re-reads
the static on every layout() call inside _layoutOverviewRulers() and
_doLayout(), so monkey-patching the field on the constructor + calling
layout() re-flows the editor widths, viewport padding, and per-canvas
ruler sizes consistently at the new value.
Implementation:
const cls: any = (this.monacoDiffEditor as any).constructor
if (cls) { cls.ENTIRE_DIFF_OVERVIEW_WIDTH = 8 }
// Also patch widget v2's OverviewRulerPart defensively
const v2Part = (monaco as any)?.editor?.OverviewRulerPart
if (v2Part) {
v2Part.ONE_OVERVIEW_WIDTH = 4
v2Part.ENTIRE_DIFF_OVERVIEW_WIDTH = 8
}
this.monacoDiffEditor.layout()
The combined ruler is now 8 px wide and serves as the only vertical
chrome on the diff page. Click + drag still work because Monaco's
delegateVerticalScrollbarPointerDown delegates pointer events to the
modified editor's underlying vertical scrollbar by SCREEN-Y coordinates,
not ruler X-width — so the drag affordance survives both the visual
scrollbar being hidden AND the ruler being narrowed to 8 px.
Both per-side scrollbars set to vertical: 'hidden' since the combined
heatmap is the single scroll affordance. Per-side overview rulers off
(overviewRulerLanes: 0) so the combined heatmap is the only mark
column.
README rewritten to describe the constant-patching technique and the
screen-Y-based click+drag delegation.
Sources for the technique:
https://github.com/microsoft/monaco-editor/blob/main/src/vs/editor/browser/widget/diffEditor/components/overviewRulerPart.ts
https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IDiffEditorBaseOptions.html1 parent e340347 commit 69ea40c
2 files changed
Lines changed: 88 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
296 | 302 | | |
297 | 303 | | |
298 | | - | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
307 | 321 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
312 | 357 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 358 | + | |
318 | 359 | | |
319 | 360 | | |
320 | 361 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | 362 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 363 | + | |
| 364 | + | |
338 | 365 | | |
339 | 366 | | |
340 | 367 | | |
| |||
0 commit comments