Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[show-hint addon] Don't cover cursor when taking up full screen height

Closes #2213
  • Loading branch information...
commit 53df1102acc3e5047fdba5c0df86b258aad55e86 1 parent 5a0ebbe
@marijnh marijnh authored
Showing with 18 additions and 13 deletions.
  1. +18 −13 addon/hint/show-hint.js
View
31 addon/hint/show-hint.js
@@ -193,8 +193,24 @@
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
(options.container || document.body).appendChild(hints);
- var box = hints.getBoundingClientRect();
- var overlapX = box.right - winW, overlapY = box.bottom - winH;
+ var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
+ if (overlapY > 0) {
+ var height = box.bottom - box.top, curTop = box.top - (pos.bottom - pos.top);
+ if (curTop - height > 0) { // Fits above cursor
+ hints.style.top = (top = curTop - height) + "px";
+ below = false;
+ } else if (height > winH) {
+ hints.style.height = (winH - 5) + "px";
+ hints.style.top = (top = pos.bottom - box.top) + "px";
+ var cursor = cm.getCursor();
+ if (data.from.ch != cursor.ch) {
+ pos = cm.cursorCoords(cursor);
+ hints.style.left = (left = pos.left) + "px";
+ box = hints.getBoundingClientRect();
+ }
+ }
+ }
+ var overlapX = box.left - winW;
if (overlapX > 0) {
if (box.right - box.left > winW) {
hints.style.width = (winW - 5) + "px";
@@ -202,17 +218,6 @@
}
hints.style.left = (left = pos.left - overlapX) + "px";
}
- if (overlapY > 0) {
- var height = box.bottom - box.top;
- if (box.top - (pos.bottom - pos.top) - height > 0) {
- overlapY = height + (pos.bottom - pos.top);
- below = false;
- } else if (height > winH) {
- hints.style.height = (winH - 5) + "px";
- overlapY -= height - winH;
- }
- hints.style.top = (top = pos.bottom - overlapY) + "px";
- }
cm.addKeyMap(this.keyMap = buildKeyMap(options, {
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
Please sign in to comment.
Something went wrong with that request. Please try again.