From 4d68dec1e9b42bc634e335ee497ced3ff5983cfa 2014-10-10 17:21:50 From: Matthias Bussonnier Date: 2014-10-10 17:21:50 Subject: [PATCH] handle somehting selected and multiple cursors and 4 tabs show content in pager --- diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 05f688a..73228e8 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -230,7 +230,7 @@ define([ event.preventDefault(); return true; } else if (event.keyCode === keycodes.tab && event.type === 'keydown' && event.shiftKey) { - if (editor.somethingSelected()){ + if (editor.somethingSelected() || editor.getSelections().length !== 1){ var anchor = editor.getCursor("anchor"); var head = editor.getCursor("head"); if( anchor.line != head.line){ @@ -244,7 +244,9 @@ define([ } else if (event.keyCode === keycodes.tab && event.type == 'keydown') { // Tab completion. this.tooltip.remove_and_cancel_tooltip(); - if (editor.somethingSelected()) { + + // completion does not work on multicursor, it might be possible though in some cases + if (editor.somethingSelected() || editor.getSelections().length > 1) { return false; } var pre_cursor = editor.getRange({line:cur.line,ch:0},cur); diff --git a/IPython/html/static/notebook/js/completer.js b/IPython/html/static/notebook/js/completer.js index 97fc0cf..2fde0c1 100644 --- a/IPython/html/static/notebook/js/completer.js +++ b/IPython/html/static/notebook/js/completer.js @@ -94,7 +94,7 @@ define([ Completer.prototype.startCompletion = function () { // call for a 'first' completion, that will set the editor and do some // special behavior like autopicking if only one completion available. - if (this.editor.somethingSelected()) return; + if (this.editor.somethingSelected()|| this.editor.getSelections().length > 1) return; this.done = false; // use to get focus back on opera this.carry_on_completion(true); @@ -143,7 +143,7 @@ define([ } // We want a single cursor position. - if (this.editor.somethingSelected()) { + if (this.editor.somethingSelected()|| editor.getSelections().length > 1) { return; } diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index af63cb1..e370efd 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -117,8 +117,7 @@ define([ Tooltip.prototype.showInPager = function (cell) { // reexecute last call in pager by appending ? to show back in pager - var that = this; - this.events.trigger('open_with_text.Pager', that._reply.content); + this.events.trigger('open_with_text.Pager', this._reply.content); this.remove_and_cancel_tooltip(); }; @@ -208,7 +207,7 @@ define([ var msg_id = cell.kernel.inspect(text, cursor_pos, callbacks); }; - // make an imediate completion request + // make an immediate completion request Tooltip.prototype.request = function (cell, hide_if_no_docstring) { // request(codecell) // Deal with extracting the text from the cell and counting @@ -222,10 +221,11 @@ define([ this._hide_if_no_docstring = hide_if_no_docstring; if(editor.somethingSelected()){ + // get only the most recent selection. text = editor.getSelection(); } - // need a permanent handel to code_mirror for future auto recall + // need a permanent handle to code_mirror for future auto recall this.code_mirror = editor; // now we treat the different number of keypress @@ -325,7 +325,7 @@ define([ this.text.scrollTop(0); }; - // Backwards compatability. + // Backwards compatibility. IPython.Tooltip = Tooltip; return {'Tooltip': Tooltip};