Show More
@@ -245,6 +245,13 var IPython = (function (IPython) { | |||
|
245 | 245 | |
|
246 | 246 | // As you type completer |
|
247 | 247 | CodeCell.prototype.finish_completing = function (matched_text, matches) { |
|
248 | if(matched_text[0]=='%'){ | |
|
249 | completing_from_magic = true; | |
|
250 | completing_to_magic = false; | |
|
251 | } else { | |
|
252 | completing_from_magic = false; | |
|
253 | completing_to_magic = false; | |
|
254 | } | |
|
248 | 255 | //return if not completing or nothing to complete |
|
249 | 256 | if (!this.is_completing || matches.length === 0) {return;} |
|
250 | 257 | |
@@ -289,7 +296,8 var IPython = (function (IPython) { | |||
|
289 | 296 | |
|
290 | 297 | // give common prefix of a array of string |
|
291 | 298 | function sharedStart(A){ |
|
292 | if(A.length == 1){return A[0]} | |
|
299 | shared=''; | |
|
300 | if(A.length == 1){shared=A[0]} | |
|
293 | 301 | if(A.length > 1 ){ |
|
294 | 302 | var tem1, tem2, s, A = A.slice(0).sort(); |
|
295 | 303 | tem1 = A[0]; |
@@ -298,9 +306,15 var IPython = (function (IPython) { | |||
|
298 | 306 | while(s && tem2.indexOf(tem1) == -1){ |
|
299 | 307 | tem1 = tem1.substring(0, --s); |
|
300 | 308 | } |
|
301 |
|
|
|
309 | shared = tem1; | |
|
310 | } | |
|
311 | if (shared[0] == '%' && !completing_from_magic) | |
|
312 | { | |
|
313 | shared = shared.substr(1); | |
|
314 | return [shared, true]; | |
|
315 | } else { | |
|
316 | return [shared, false]; | |
|
302 | 317 | } |
|
303 | return ""; | |
|
304 | 318 | } |
|
305 | 319 | |
|
306 | 320 | |
@@ -377,8 +391,13 var IPython = (function (IPython) { | |||
|
377 | 391 | { |
|
378 | 392 | // If autopick an only one match, past. |
|
379 | 393 | // Used to 'pick' when pressing tab |
|
394 | var prefix = ''; | |
|
395 | if(completing_to_magic && !completing_from_magic) | |
|
396 | { | |
|
397 | prefix='%'; | |
|
398 | } | |
|
380 | 399 | if (matches.length < 1) { |
|
381 | insert(typed_text,event); | |
|
400 | insert(prefix+typed_text,event); | |
|
382 | 401 | if(event != null){ |
|
383 | 402 | event.stopPropagation(); |
|
384 | 403 | event.preventDefault(); |
@@ -389,11 +408,12 var IPython = (function (IPython) { | |||
|
389 | 408 | event.stopPropagation(); |
|
390 | 409 | event.preventDefault(); |
|
391 | 410 | } |
|
411 | return; | |
|
392 | 412 | } |
|
393 | 413 | //clear the previous completion if any |
|
394 | update(typed_text,event); | |
|
414 | update(prefix+typed_text,event); | |
|
395 | 415 | complete.children().children().remove(); |
|
396 | $('#asyoutype').html("<b>"+matched_text+"</b>"+typed_text.substr(matched_text.length)); | |
|
416 | $('#asyoutype').html("<b>"+prefix+matched_text+"</b>"+typed_text.substr(matched_text.length)); | |
|
397 | 417 | select = $('#asyoutypeselect'); |
|
398 | 418 | for (var i = 0; i<matches.length; ++i) { |
|
399 | 419 | select.append($('<option/>').html(matches[i])); |
@@ -421,7 +441,9 var IPython = (function (IPython) { | |||
|
421 | 441 | |
|
422 | 442 | // So a first actual completion. see if all the completion start wit |
|
423 | 443 | // the same letter and complete if necessary |
|
424 |
f |
|
|
444 | ff = sharedStart(matches) | |
|
445 | fastForward = ff[0]; | |
|
446 | completing_to_magic = ff[1]; | |
|
425 | 447 | typed_characters = fastForward.substr(matched_text.length); |
|
426 | 448 | complete_with(matches,matched_text+typed_characters,true,null); |
|
427 | 449 | filterd = matches; |
@@ -460,7 +482,9 var IPython = (function (IPython) { | |||
|
460 | 482 | var newchar = String.fromCharCode(code); |
|
461 | 483 | typed_characters = typed_characters+newchar; |
|
462 | 484 | } else if (code == key.tab) { |
|
463 |
f |
|
|
485 | ff = sharedStart(matches) | |
|
486 | fastForward = ff[0]; | |
|
487 | completing_to_magic = ff[1]; | |
|
464 | 488 | ffsub = fastForward.substr(matched_text.length+typed_characters.length); |
|
465 | 489 | typed_characters = typed_characters+ffsub; |
|
466 | 490 | autopick = true; |
@@ -482,6 +506,8 var IPython = (function (IPython) { | |||
|
482 | 506 | } |
|
483 | 507 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); |
|
484 | 508 | filterd = matches.filter(function(x){return re.test(x)}); |
|
509 | ff = sharedStart(filterd); | |
|
510 | completing_to_magic = ff[1]; | |
|
485 | 511 | complete_with(filterd,matched_text+typed_characters,autopick,event); |
|
486 | 512 | } else if( code == key.esc) { |
|
487 | 513 | // dismiss the completer and go back to before invoking it |
General Comments 0
You need to be logged in to leave comments.
Login now