Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit 89df69d

Browse files
committed
[show-hint addon] Close pop-up on blur, make page-up work when near top of list
1 parent b37017c commit 89df69d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

addon/hint/show-hint.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ CodeMirror.showHint = function(cm, getHints, options) {
5252
}
5353

5454
function changeActive(i) {
55-
if (i < 0 || i >= completions.length || selectedHint == i) return;
55+
i = Math.max(0, Math.min(i, completions.length - 1));
56+
if (selectedHint == i) return;
5657
hints.childNodes[selectedHint].className = "CodeMirror-hint";
5758
var node = hints.childNodes[selectedHint = i];
5859
node.className = "CodeMirror-hint CodeMirror-hint-active";
@@ -85,6 +86,7 @@ CodeMirror.showHint = function(cm, getHints, options) {
8586

8687
cm.addKeyMap(ourMap);
8788
cm.on("cursorActivity", cursorActivity);
89+
cm.on("blur", close);
8890
CodeMirror.on(hints, "dblclick", function(e) {
8991
var t = e.target || e.srcElement;
9092
if (t.hintId != null) {selectedHint = t.hintId; pick();}
@@ -104,6 +106,7 @@ CodeMirror.showHint = function(cm, getHints, options) {
104106
hints.parentNode.removeChild(hints);
105107
cm.removeKeyMap(ourMap);
106108
cm.off("cursorActivity", cursorActivity);
109+
cm.off("blur", close);
107110
}
108111
function pick() {
109112
cm.replaceRange(completions[selectedHint], result.from, result.to);

0 commit comments

Comments
 (0)