From 671d2b94996ac71d56b2d05d5fe694ed7d84fa59 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 12:27:35 -0700 Subject: upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open. Signed-off-by: Ananya Sen --- imports/codemirror/lib/util/simple-hint.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'imports/codemirror/lib/util/simple-hint.js') diff --git a/imports/codemirror/lib/util/simple-hint.js b/imports/codemirror/lib/util/simple-hint.js index b38f3892..7decd587 100644 --- a/imports/codemirror/lib/util/simple-hint.js +++ b/imports/codemirror/lib/util/simple-hint.js @@ -29,6 +29,10 @@ complete.style.left = pos.x + "px"; complete.style.top = pos.yBot + "px"; document.body.appendChild(complete); + // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. + var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth); + if(winW - pos.x < sel.clientWidth) + complete.style.left = (pos.x - sel.clientWidth) + "px"; // Hack to hide the scrollbar. if (completions.length <= 10) complete.style.width = (sel.clientWidth - 1) + "px"; @@ -53,6 +57,8 @@ else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();} else if (code != 38 && code != 40) { close(); editor.focus(); + // Pass the event to the CodeMirror instance so that it can handle things like backspace properly. + editor.triggerOnKeyDown(event); setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50); } }); -- cgit v1.2.3