##// END OF EJS Templates
Fixing tab completion edge cases.
Brian E. Granger -
Show More
@@ -47,7 +47,8 b' var IPython = (function (IPython) {'
47 47 if (event.keyCode === 13 && event.shiftKey) {
48 48 // Always ignore shift-enter in CodeMirror as we handle it.
49 49 return true;
50 } else if (event.keyCode === 9) {
50 } else if (event.keyCode === 9 && event.type == 'keydown') {
51 // Tab completion.
51 52 var cur = editor.getCursor();
52 53 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
53 54 if (pre_cursor === "") {
@@ -79,18 +80,24 b' var IPython = (function (IPython) {'
79 80 return false;
80 81 };
81 82 } else {
82 if (this.is_completing && this.completion_cursor !== editor.getCursor()) {
83 this.is_completing = false;
84 this.completion_cursor = null;
85 }
83 // keypress/keyup also trigger on TAB press, and we don't want to use those
84 // to disable tab completion.
85 if (this.is_completing && event.keyCode !== 9) {
86 var ed_cur = editor.getCursor();
87 var cc_cur = this.completion_cursor;
88 if (ed_cur.line !== cc_cur.line || ed_cur.ch !== cc_cur.ch) {
89 this.is_completing = false;
90 this.completion_cursor = null;
91 };
92 };
86 93 return false;
87 94 };
88 95 };
89 96
90 97
91 98 CodeCell.prototype.finish_completing = function (matched_text, matches) {
92 if (!this.is_completing || matches.length === 0) {return;}
93 99 // console.log("Got matches", matched_text, matches);
100 if (!this.is_completing || matches.length === 0) {return;}
94 101
95 102 var that = this;
96 103 var cur = this.completion_cursor;
@@ -151,7 +158,7 b' var IPython = (function (IPython) {'
151 158 // but we want the default action.
152 159 event.stopPropagation();
153 160 } else {
154 // All other key presses simple exit completion.
161 // All other key presses exit completion.
155 162 event.stopPropagation();
156 163 event.preventDefault();
157 164 close();
General Comments 0
You need to be logged in to leave comments. Login now