Show More
@@ -45,13 +45,23 b' var IPython = (function (IPython) {' | |||||
45 | if (event.keyCode === 13 && event.shiftKey) { |
|
45 | if (event.keyCode === 13 && event.shiftKey) { | |
46 | // Always ignore shift-enter in CodeMirror as we handle it. |
|
46 | // Always ignore shift-enter in CodeMirror as we handle it. | |
47 | return true; |
|
47 | return true; | |
48 | } else if (event.keyCode == 32 && (event.ctrlKey || event.metaKey) && !event.altKey) { |
|
48 | // } else if (event.keyCode == 32 && (event.ctrlKey || event.metaKey) && !event.altKey) { | |
49 | event.stop(); |
|
49 | } else if (event.keyCode == 9) { | |
50 | var cur = editor.getCursor(); |
|
50 | var cur = editor.getCursor(); | |
51 |
var |
|
51 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim(); | |
52 | this.is_completing = true; |
|
52 | if (pre_cursor === "") { | |
53 | this.completion_cursor = cur; |
|
53 | // Don't autocomplete if the part of the line before the cursor is empty. | |
54 | IPython.notebook.complete_cell(this, line, cur.ch); |
|
54 | // In this case, let CodeMirror handle indentation. | |
|
55 | return false; | |||
|
56 | } else { | |||
|
57 | // Autocomplete the current line. | |||
|
58 | event.stop(); | |||
|
59 | var line = editor.getLine(cur.line); | |||
|
60 | this.is_completing = true; | |||
|
61 | this.completion_cursor = cur; | |||
|
62 | IPython.notebook.complete_cell(this, line, cur.ch); | |||
|
63 | return true; | |||
|
64 | } | |||
55 | } else { |
|
65 | } else { | |
56 | if (this.is_completing && this.completion_cursor !== editor.getCursor()) { |
|
66 | if (this.is_completing && this.completion_cursor !== editor.getCursor()) { | |
57 | this.is_completing = false; |
|
67 | this.is_completing = false; |
General Comments 0
You need to be logged in to leave comments.
Login now