##// END OF EJS Templates
Fix #4777 and #7887...
Matthias Bussonnier -
Show More
@@ -507,11 +507,12 b' define(['
507 /**
507 /**
508 * turn absolute cursor postion into CodeMirror col, ch cursor
508 * turn absolute cursor postion into CodeMirror col, ch cursor
509 */
509 */
510 var i, line;
510 var i, line, next_line;
511 var offset = 0;
511 var offset = 0;
512 for (i = 0, line=cm.getLine(i); line !== undefined; i++, line=cm.getLine(i)) {
512 for (i = 0, next_line=cm.getLine(i); next_line !== undefined; i++, next_line=cm.getLine(i)) {
513 if (offset + line.length < cursor_pos) {
513 line = next_line;
514 offset += line.length + 1;
514 if (offset + next_line.length < cursor_pos) {
515 offset += next_line.length + 1;
515 } else {
516 } else {
516 return {
517 return {
517 line : i,
518 line : i,
@@ -521,8 +522,8 b' define(['
521 }
522 }
522 // reached end, return endpoint
523 // reached end, return endpoint
523 return {
524 return {
524 ch : line.length - 1,
525 line : i - 1,
525 line : i - 1,
526 ch : line.length - 1,
526 };
527 };
527 };
528 };
528
529
@@ -321,9 +321,10 b' define(['
321
321
322 Completer.prototype.keydown = function (event) {
322 Completer.prototype.keydown = function (event) {
323 var code = event.keyCode;
323 var code = event.keyCode;
324 var that = this;
325
324
326 // Enter
325 // Enter
326 var options;
327 var index;
327 if (code == keycodes.enter) {
328 if (code == keycodes.enter) {
328 event.codemirrorIgnore = true;
329 event.codemirrorIgnore = true;
329 event._ipkmIgnore = true;
330 event._ipkmIgnore = true;
@@ -341,14 +342,11 b' define(['
341 // like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
342 // like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
342 // to erase py
343 // to erase py
343 var sh = shared_start(this.raw_result, true);
344 var sh = shared_start(this.raw_result, true);
344 if (sh) {
345 if (sh.str !== '') {
345 this.insert(sh);
346 this.insert(sh);
346 }
347 }
347 this.close();
348 this.close();
348 //reinvoke self
349 this.carry_on_completion();
349 setTimeout(function () {
350 that.carry_on_completion();
351 }, 50);
352 } else if (code == keycodes.up || code == keycodes.down) {
350 } else if (code == keycodes.up || code == keycodes.down) {
353 // need to do that to be able to move the arrow
351 // need to do that to be able to move the arrow
354 // when on the first or last line ofo a code cell
352 // when on the first or last line ofo a code cell
@@ -356,8 +354,8 b' define(['
356 event._ipkmIgnore = true;
354 event._ipkmIgnore = true;
357 event.preventDefault();
355 event.preventDefault();
358
356
359 var options = this.sel.find('option');
357 options = this.sel.find('option');
360 var index = this.sel[0].selectedIndex;
358 index = this.sel[0].selectedIndex;
361 if (code == keycodes.up) {
359 if (code == keycodes.up) {
362 index--;
360 index--;
363 }
361 }
@@ -369,8 +367,8 b' define(['
369 } else if (code == keycodes.pageup || code == keycodes.pagedown) {
367 } else if (code == keycodes.pageup || code == keycodes.pagedown) {
370 event._ipkmIgnore = true;
368 event._ipkmIgnore = true;
371
369
372 var options = this.sel.find('option');
370 options = this.sel.find('option');
373 var index = this.sel[0].selectedIndex;
371 index = this.sel[0].selectedIndex;
374 if (code == keycodes.pageup) {
372 if (code == keycodes.pageup) {
375 index -= 10; // As 10 is the hard coded size of the drop down menu
373 index -= 10; // As 10 is the hard coded size of the drop down menu
376 } else {
374 } else {
General Comments 0
You need to be logged in to leave comments. Login now