don't care about lleading prct in completion

mainly to avoid weird shared start with cell magics
pull/37/head
Matthias BUSSONNIER 14 years ago
parent 9ebbfe3f22
commit cc62fc63f9

@ -8,6 +8,13 @@ var IPython = (function (IPython) {
// easyier key mapping
var key = IPython.utils.keycodes;
function prepend_n_prc(str,n)
{
for( var i =0; i< n;i++)
{ str = '%'+str }
return str;
}
function _existing_completion(item, completion_array){
for( var c in completion_array ) {
if(completion_array[c].substr(-item.length) == item)
@ -17,14 +24,26 @@ var IPython = (function (IPython) {
}
// what is the common start of all completions
function shared_start(B) {
function shared_start(B,drop_prct) {
if (B.length == 1) {
return B[0];
}
var A = new Array();
var common;
var min_lead_prct = 10;
for (var i = 0; i < B.length; i++) {
A.push(B[i].str);
var str = B[i].str
var localmin = 0
if(drop_prct == true){
while ( str.substr(0,1) == '%') {
localmin = localmin+1;
str = str.substring(1);
}
}
min_lead_prct = Math.min(min_lead_prct,localmin);
A.push(str);
}
if (A.length > 1) {
var tem1, tem2, s;
A = A.slice(0).sort();
@ -35,10 +54,10 @@ var IPython = (function (IPython) {
tem1 = tem1.substring(0, --s);
}
if (tem1 == "" || tem2.indexOf(tem1) != 0) {
return null;
return prepend_n_prc('',min_lead_prct);
}
return {
str: tem1,
str: prepend_n_prc(tem1,min_lead_prct),
type: "computed",
from: B[0].from,
to: B[0].to
@ -257,7 +276,7 @@ var IPython = (function (IPython) {
//Check that shared start is not null which can append with prefixed completion
// 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);
var sh = shared_start(this.raw_result,true);
if (sh) {
this.insert(sh);
}

Loading…
Cancel
Save