Show More
@@ -318,21 +318,23 b' var IPython = (function (IPython) {' | |||
|
318 | 318 | }; |
|
319 | 319 | |
|
320 | 320 | // insert the given text and exit the completer |
|
321 | var insert = function (selected_text) { | |
|
321 | var insert = function (selected_text, event) { | |
|
322 | 322 | that.code_mirror.replaceRange( |
|
323 | 323 | selected_text, |
|
324 | 324 | {line: cur.line, ch: (cur.ch-matched_text.length)}, |
|
325 | 325 | {line: cur.line, ch: cur.ch} |
|
326 | 326 | ); |
|
327 | event.stopPropagation(); | |
|
328 |
event. |
|
|
327 | if(event != null){ | |
|
328 | event.stopPropagation(); | |
|
329 | event.preventDefault(); | |
|
330 | } | |
|
329 | 331 | close(); |
|
330 | 332 | setTimeout(function(){that.code_mirror.focus();}, 50); |
|
331 | 333 | }; |
|
332 | 334 | |
|
333 | 335 | // insert the curent highlited selection and exit |
|
334 | 336 | var pick = function () { |
|
335 | insert(select.val()[0]); | |
|
337 | insert(select.val()[0],null); | |
|
336 | 338 | }; |
|
337 | 339 | |
|
338 | 340 | |
@@ -340,14 +342,22 b' var IPython = (function (IPython) {' | |||
|
340 | 342 | // matches, update the pseuso typing field. autopick insert match if |
|
341 | 343 | // only one left, in no matches (anymore) dismiss itself by pasting |
|
342 | 344 | // what the user have typed until then |
|
343 | var complete_with = function(matches,typed_text,autopick) | |
|
345 | var complete_with = function(matches,typed_text,autopick,event) | |
|
344 | 346 | { |
|
345 | 347 | // If autopick an only one match, past. |
|
346 | 348 | // Used to 'pick' when pressing tab |
|
347 | 349 | if (matches.length < 1) { |
|
348 | insert(typed_text); | |
|
350 | insert(typed_text,event); | |
|
351 | if(event !=null){ | |
|
352 | event.stopPropagation(); | |
|
353 | event.preventDefault(); | |
|
354 | } | |
|
349 | 355 | } else if (autopick && matches.length==1) { |
|
350 | insert(matches[0]); | |
|
356 | insert(matches[0],event); | |
|
357 | if(event !=null){ | |
|
358 | event.stopPropagation(); | |
|
359 | event.preventDefault(); | |
|
360 | } | |
|
351 | 361 | } |
|
352 | 362 | //clear the previous completion if any |
|
353 | 363 | complete.children().children().remove(); |
@@ -381,7 +391,7 b' var IPython = (function (IPython) {' | |||
|
381 | 391 | // the same letter and complete if necessary |
|
382 | 392 | fastForward = sharedStart(matches) |
|
383 | 393 | typed_characters= fastForward.substr(matched_text.length); |
|
384 | complete_with(matches,matched_text+typed_characters,true); | |
|
394 | complete_with(matches,matched_text+typed_characters,true,null); | |
|
385 | 395 | filterd=matches; |
|
386 | 396 | // Give focus to select, and make it filter the match as the user type |
|
387 | 397 | // by filtering the previous matches. Called by .keypress and .keydown |
@@ -407,8 +417,8 b' var IPython = (function (IPython) {' | |||
|
407 | 417 | // but we want the default action. |
|
408 | 418 | event.stopPropagation(); |
|
409 | 419 | //} else if ( key.isCompSymbol(code)|| (code==key.backspace)||(code==key.tab && down)){ |
|
410 | } else if ( (code==key.backspace)||(code==key.tab) || press || key.isCompSymbol(code)){ | |
|
411 | if((code != key.backspace) && (code != key.tab) && press) | |
|
420 | } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){ | |
|
421 | if( key.isCompSymbol(code) && press) | |
|
412 | 422 | { |
|
413 | 423 | var newchar = String.fromCharCode(code); |
|
414 | 424 | typed_characters=typed_characters+newchar; |
@@ -419,22 +429,22 b' var IPython = (function (IPython) {' | |||
|
419 | 429 | autopick=true; |
|
420 | 430 | event.stopPropagation(); |
|
421 | 431 | event.preventDefault(); |
|
422 | } else if (code == key.backspace) { | |
|
432 | } else if (code == key.backspace && down) { | |
|
423 | 433 | // cancel if user have erase everything, otherwise decrease |
|
424 | 434 | // what we filter with |
|
425 | 435 | if (typed_characters.length <= 0) |
|
426 | 436 | { |
|
427 | insert(matched_text) | |
|
437 | insert(matched_text,event) | |
|
428 | 438 | } |
|
429 | 439 | typed_characters=typed_characters.substr(0,typed_characters.length-1); |
|
430 | } | |
|
440 | }else{return} | |
|
431 | 441 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); |
|
432 | 442 | filterd = matches.filter(function(x){return re.test(x)}); |
|
433 | complete_with(filterd,matched_text+typed_characters,autopick); | |
|
443 | complete_with(filterd,matched_text+typed_characters,autopick,event); | |
|
434 | 444 | } else if(down){ // abort only on .keydown |
|
435 | 445 | // abort with what the user have pressed until now |
|
436 | 446 | console.log('aborting with keycode : '+code+' is down :'+down); |
|
437 | insert(matched_text+typed_characters); | |
|
447 | insert(matched_text+typed_characters,event); | |
|
438 | 448 | } |
|
439 | 449 | } |
|
440 | 450 | select.keydown(function (event) { |
General Comments 0
You need to be logged in to leave comments.
Login now