Merge pull request #7889 from Carreau/after-one-year

Js completion traceback, erase line on tab, and double complete.
Matthias Bussonnier 11 years ago
commit 242fc93f93

@ -507,11 +507,12 @@ define([
/**
* turn absolute cursor postion into CodeMirror col, ch cursor
*/
var i, line;
var i, line, next_line;
var offset = 0;
for (i = 0, line=cm.getLine(i); line !== undefined; i++, line=cm.getLine(i)) {
if (offset + line.length < cursor_pos) {
offset += line.length + 1;
for (i = 0, next_line=cm.getLine(i); next_line !== undefined; i++, next_line=cm.getLine(i)) {
line = next_line;
if (offset + next_line.length < cursor_pos) {
offset += next_line.length + 1;
} else {
return {
line : i,
@ -521,8 +522,8 @@ define([
}
// reached end, return endpoint
return {
ch : line.length - 1,
line : i - 1,
ch : line.length - 1,
};
};

@ -323,9 +323,10 @@ define([
Completer.prototype.keydown = function (event) {
var code = event.keyCode;
var that = this;
// Enter
var options;
var index;
if (code == keycodes.enter) {
event.codemirrorIgnore = true;
event._ipkmIgnore = true;
@ -343,14 +344,11 @@ define([
// like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
// to erase py
var sh = shared_start(this.raw_result, true);
if (sh) {
if (sh.str !== '') {
this.insert(sh);
}
this.close();
//reinvoke self
setTimeout(function () {
that.carry_on_completion();
}, 50);
this.carry_on_completion();
} else if (code == keycodes.up || code == keycodes.down) {
// need to do that to be able to move the arrow
// when on the first or last line ofo a code cell
@ -358,8 +356,8 @@ define([
event._ipkmIgnore = true;
event.preventDefault();
var options = this.sel.find('option');
var index = this.sel[0].selectedIndex;
options = this.sel.find('option');
index = this.sel[0].selectedIndex;
if (code == keycodes.up) {
index--;
}
@ -371,8 +369,8 @@ define([
} else if (code == keycodes.pageup || code == keycodes.pagedown) {
event._ipkmIgnore = true;
var options = this.sel.find('option');
var index = this.sel[0].selectedIndex;
options = this.sel.find('option');
index = this.sel[0].selectedIndex;
if (code == keycodes.pageup) {
index -= 10; // As 10 is the hard coded size of the drop down menu
} else {

Loading…
Cancel
Save