Skip to content

Commit 352e34c

Browse files
committed
[show-hint addon] Fix scrollbar on hint widget overlapping text
See https://discuss.codemirror.net/t/width-of-sql-hint-dropdown-in-firefox-is-not-always-correct/757
1 parent 320b301 commit 352e34c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

addon/hint/show-hint.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
padding: 0 4px;
2727
border-radius: 2px;
2828
max-width: 19em;
29-
overflow: hidden;
3029
white-space: pre;
3130
color: black;
3231
cursor: pointer;

addon/hint/show-hint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
230230
(completion.options.container || document.body).appendChild(hints);
231231
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
232+
var scrolls = hints.scrollHeight > hints.clientHeight + 1
232233
if (overlapY > 0) {
233234
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
234235
if (curTop - height > 0) { // Fits above cursor
@@ -253,6 +254,7 @@
253254
}
254255
hints.style.left = (left = pos.left - overlapX) + "px";
255256
}
257+
if (scrolls) hints.style.paddingRight = cm.display.nativeBarWidth + "px"
256258

257259
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
258260
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },

0 commit comments

Comments
 (0)