Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Notebook now uses tab for autocompletion.

  • Loading branch information...
commit 4b71ab3f1772093e8c2930f2aabce482f7f64c9f 1 parent 68687d2
@ellisonbg ellisonbg authored
Showing with 16 additions and 6 deletions.
  1. +16 −6 IPython/frontend/html/notebook/static/js/codecell.js
View
22 IPython/frontend/html/notebook/static/js/codecell.js
@@ -45,13 +45,23 @@ var IPython = (function (IPython) {
if (event.keyCode === 13 && event.shiftKey) {
// Always ignore shift-enter in CodeMirror as we handle it.
return true;
- } else if (event.keyCode == 32 && (event.ctrlKey || event.metaKey) && !event.altKey) {
- event.stop();
+ // } else if (event.keyCode == 32 && (event.ctrlKey || event.metaKey) && !event.altKey) {
+ } else if (event.keyCode == 9) {
var cur = editor.getCursor();
- var line = editor.getLine(cur.line);
- this.is_completing = true;
- this.completion_cursor = cur;
- IPython.notebook.complete_cell(this, line, cur.ch);
+ var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
+ if (pre_cursor === "") {
+ // Don't autocomplete if the part of the line before the cursor is empty.
+ // In this case, let CodeMirror handle indentation.
+ return false;
+ } else {
+ // Autocomplete the current line.
+ event.stop();
+ var line = editor.getLine(cur.line);
+ this.is_completing = true;
+ this.completion_cursor = cur;
+ IPython.notebook.complete_cell(this, line, cur.ch);
+ return true;
+ }
} else {
if (this.is_completing && this.completion_cursor !== editor.getCursor()) {
this.is_completing = false;
Please sign in to comment.
Something went wrong with that request. Please try again.