##// END OF EJS Templates
don't care about lleading prct in completion...
Matthias BUSSONNIER -
Show More
@@ -8,6 +8,13 b' var IPython = (function (IPython) {'
8 8 // easyier key mapping
9 9 var key = IPython.utils.keycodes;
10 10
11 function prepend_n_prc(str,n)
12 {
13 for( var i =0; i< n;i++)
14 { str = '%'+str }
15 return str;
16 }
17
11 18 function _existing_completion(item, completion_array){
12 19 for( var c in completion_array ) {
13 20 if(completion_array[c].substr(-item.length) == item)
@@ -17,14 +24,26 b' var IPython = (function (IPython) {'
17 24 }
18 25
19 26 // what is the common start of all completions
20 function shared_start(B) {
27 function shared_start(B,drop_prct) {
21 28 if (B.length == 1) {
22 29 return B[0];
23 30 }
24 31 var A = new Array();
32 var common;
33 var min_lead_prct = 10;
25 34 for (var i = 0; i < B.length; i++) {
26 A.push(B[i].str);
35 var str = B[i].str
36 var localmin = 0
37 if(drop_prct == true){
38 while ( str.substr(0,1) == '%') {
39 localmin = localmin+1;
40 str = str.substring(1);
41 }
42 }
43 min_lead_prct = Math.min(min_lead_prct,localmin);
44 A.push(str);
27 45 }
46
28 47 if (A.length > 1) {
29 48 var tem1, tem2, s;
30 49 A = A.slice(0).sort();
@@ -35,10 +54,10 b' var IPython = (function (IPython) {'
35 54 tem1 = tem1.substring(0, --s);
36 55 }
37 56 if (tem1 == "" || tem2.indexOf(tem1) != 0) {
38 return null;
57 return prepend_n_prc('',min_lead_prct);
39 58 }
40 59 return {
41 str: tem1,
60 str: prepend_n_prc(tem1,min_lead_prct),
42 61 type: "computed",
43 62 from: B[0].from,
44 63 to: B[0].to
@@ -257,7 +276,7 b' var IPython = (function (IPython) {'
257 276 //Check that shared start is not null which can append with prefixed completion
258 277 // like %pylab , pylab have no shred start, and ff will result in py<tab><tab>
259 278 // to erase py
260 var sh = shared_start(this.raw_result);
279 var sh = shared_start(this.raw_result,true);
261 280 if (sh) {
262 281 this.insert(sh);
263 282 }
General Comments 0
You need to be logged in to leave comments. Login now