|
|
|
|
@ -48,8 +48,7 @@ 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) {
|
|
|
|
|
} else if (event.keyCode == 9) {
|
|
|
|
|
} else if (event.keyCode === 9) {
|
|
|
|
|
var cur = editor.getCursor();
|
|
|
|
|
var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
|
|
|
|
|
if (pre_cursor === "") {
|
|
|
|
|
@ -65,6 +64,21 @@ var IPython = (function (IPython) {
|
|
|
|
|
IPython.notebook.complete_cell(this, line, cur.ch);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else if (event.keyCode === 8) {
|
|
|
|
|
// If backspace and the line ends with 4 spaces, remove them.
|
|
|
|
|
var cur = editor.getCursor();
|
|
|
|
|
var line = editor.getLine(cur.line);
|
|
|
|
|
var ending = line.slice(-4);
|
|
|
|
|
if (ending === ' ') {
|
|
|
|
|
editor.replaceRange('',
|
|
|
|
|
{line: cur.line, ch: cur.ch-4},
|
|
|
|
|
{line: cur.line, ch: cur.ch}
|
|
|
|
|
);
|
|
|
|
|
event.stop();
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
if (this.is_completing && this.completion_cursor !== editor.getCursor()) {
|
|
|
|
|
this.is_completing = false;
|
|
|
|
|
|