diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js
index ea0092818..eb4b60f61 100644
--- a/IPython/html/static/notebook/js/codecell.js
+++ b/IPython/html/static/notebook/js/codecell.js
@@ -202,8 +202,10 @@ var IPython = (function (IPython) {
return true;
} else if (event.keyCode === key.TAB && event.type == 'keydown') {
// Tab completion.
- //Do not trim here because of tooltip
- if (editor.somethingSelected()) { return false; }
+ IPython.tooltip.remove_and_cancel_tooltip();
+ if (editor.somethingSelected()) {
+ return false;
+ }
var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
if (pre_cursor.trim() === "") {
// Don't autocomplete if the part of the line before the cursor
@@ -443,7 +445,8 @@ var IPython = (function (IPython) {
var data = IPython.Cell.prototype.toJSON.apply(this);
data.input = this.get_text();
data.cell_type = 'code';
- if (this.input_prompt_number) {
+ // is finite protect against undefined and '*' value
+ if (isFinite(this.input_prompt_number)) {
data.prompt_number = this.input_prompt_number;
}
var outputs = this.output_area.toJSON();