From 7b7a00b419ee99fc1b5a929a7af38967404efc66 2013-09-08 23:58:39 From: Takeshi Kanmae Date: 2013-09-08 23:58:39 Subject: [PATCH] Have remove_and_cancel_tooltip() return a boolean --- diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 022f821..492b902 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -179,12 +179,7 @@ var IPython = (function (IPython) { return true; }; } else if (event.which === key.ESC) { - if (!IPython.tooltip._hidden) { - IPython.tooltip.remove_and_cancel_tooltip(true); - return true; - } else { - return false; - } + return IPython.tooltip.remove_and_cancel_tooltip(true); } else if (event.which === key.DOWNARROW && event.type === 'keydown') { // If we are not at the bottom, let CM handle the down arrow and // prevent the global keydown handler from handling it. diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index 4d324fe..e1acf48 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -161,16 +161,23 @@ var IPython = (function (IPython) { this.code_mirror = null; } + // return true on successfully removing a visible tooltip; otherwise return + // false. Tooltip.prototype.remove_and_cancel_tooltip = function (force) { // note that we don't handle closing directly inside the calltip // as in the completer, because it is not focusable, so won't // get the event. - if (this._sticky == false || force == true) { - this.cancel_stick(); - this._hide(); + if (this._hidden === false) { + if (this._sticky == false || force == true) { + this.cancel_stick(); + this._hide(); + } + this.cancel_pending(); + this.reset_tabs_function(); + return true; + } else { + return false; } - this.cancel_pending(); - this.reset_tabs_function(); } // cancel autocall done after '(' for example. @@ -335,7 +342,7 @@ var IPython = (function (IPython) { if (docstring == null) { docstring = reply.docstring; } - + if (docstring == null) { // For reals this time, no docstring if (this._hide_if_no_docstring) {