From 23d86c53a741439476e07dc6c49ddb9b050d8b5a Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 30 Jul 2021 15:38:38 +0300 Subject: [PATCH] properly account for scrollbar in applies-to widget --- edit/edit.css | 3 +-- edit/moz-section-widget.js | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/edit/edit.css b/edit/edit.css index 60de98dd..2ceddfe5 100644 --- a/edit/edit.css +++ b/edit/edit.css @@ -926,8 +926,7 @@ body.linter-disabled .hidden-unless-compact { /************ line widget *************/ .CodeMirror-linewidget .applies-to { margin: 1em 0; - padding: .75rem .75rem .25rem; - padding-right: calc(1em + 20px); + padding: .75rem calc(.25rem + var(--cm-bar-width, 0)) .25rem .75rem; } .CodeMirror-linewidget .applies-to li { diff --git a/edit/moz-section-widget.js b/edit/moz-section-widget.js index e1f79a12..60d95f18 100644 --- a/edit/moz-section-widget.js +++ b/edit/moz-section-widget.js @@ -286,6 +286,13 @@ function MozSectionWidget(cm, finder = MozSectionFinder(cm)) { above: true, height, }); + widget.on('redraw', () => { + const value = cm.display.barWidth + 'px'; + if (widget[KEY] !== value) { + widget[KEY] = value; + node.style.setProperty('--cm-bar-width', value); + } + }); } if (!funcHeight) { funcHeight = node.offsetHeight / (sec.funcs.length || 1);