Show More
@@ -9,8 +9,9 var IPython = (function (IPython) { | |||
|
9 | 9 | var key = IPython.utils.keycodes; |
|
10 | 10 | |
|
11 | 11 | function prepend_n_prc(str, n) { |
|
12 | for( var i =0 ; i< n ; i++) | |
|
13 |
|
|
|
12 | for( var i =0 ; i< n ; i++){ | |
|
13 | str = '%'+str ; | |
|
14 | } | |
|
14 | 15 | return str; |
|
15 | 16 | } |
|
16 | 17 | |
@@ -33,7 +34,7 var IPython = (function (IPython) { | |||
|
33 | 34 | for (var i = 0; i < B.length; i++) { |
|
34 | 35 | var str = B[i].str; |
|
35 | 36 | var localmin = 0; |
|
36 | if(drop_prct == true){ | |
|
37 | if(drop_prct === true){ | |
|
37 | 38 | while ( str.substr(0, 1) == '%') { |
|
38 | 39 | localmin = localmin+1; |
|
39 | 40 | str = str.substring(1); |
@@ -52,13 +53,13 var IPython = (function (IPython) { | |||
|
52 | 53 | while (s && tem2.indexOf(tem1) == -1) { |
|
53 | 54 | tem1 = tem1.substring(0, --s); |
|
54 | 55 | } |
|
55 | if (tem1 == "" || tem2.indexOf(tem1) != 0) { | |
|
56 | if (tem1 === "" || tem2.indexOf(tem1) !== 0) { | |
|
56 | 57 | return { |
|
57 | 58 | str:prepend_n_prc('', min_lead_prct), |
|
58 | 59 | type: "computed", |
|
59 | 60 | from: B[0].from, |
|
60 | 61 | to: B[0].to |
|
61 | } | |
|
62 | }; | |
|
62 | 63 | } |
|
63 | 64 | return { |
|
64 | 65 | str: prepend_n_prc(tem1, min_lead_prct), |
@@ -94,10 +95,28 var IPython = (function (IPython) { | |||
|
94 | 95 | this.carry_on_completion(true); |
|
95 | 96 | }; |
|
96 | 97 | |
|
97 | Completer.prototype.carry_on_completion = function (ff) { | |
|
98 | ||
|
99 | // easy access for julia to monkeypatch | |
|
100 | // | |
|
101 | Completer.reinvoke_re = /[%0-9a-z._/\\:~-]/i; | |
|
102 | ||
|
103 | Completer.prototype.reinvoke= function(pre_cursor, block, cursor){ | |
|
104 | return Completer.reinvoke_re.test(pre_cursor); | |
|
105 | } | |
|
106 | ||
|
107 | /** | |
|
108 | * | |
|
109 | * pass true as parameter if this is the first invocation of the completer | |
|
110 | * this will prevent the completer to dissmiss itself if it is not on a | |
|
111 | * word boundary like pressing tab after a space, and make it autopick the | |
|
112 | * only choice if there is only one which prevent from popping the UI. as | |
|
113 | * well as fast-forwarding the typing if all completion have a common | |
|
114 | * shared start | |
|
115 | **/ | |
|
116 | Completer.prototype.carry_on_completion = function (first_invocation) { | |
|
98 | 117 | // Pass true as parameter if you want the commpleter to autopick when |
|
99 | 118 | // only one completion. This function is automatically reinvoked at |
|
100 |
// each keystroke with f |
|
|
119 | // each keystroke with first_invocation = false | |
|
101 | 120 | var cur = this.editor.getCursor(); |
|
102 | 121 | var line = this.editor.getLine(cur.line); |
|
103 | 122 | var pre_cursor = this.editor.getRange({ |
@@ -107,18 +126,21 var IPython = (function (IPython) { | |||
|
107 | 126 | |
|
108 | 127 | // we need to check that we are still on a word boundary |
|
109 | 128 | // because while typing the completer is still reinvoking itself |
|
110 | if (!/[%0-9a-z._/\\:~-]/i.test(pre_cursor)) { | |
|
129 | // so dismiss if we are on a "bad" caracter | |
|
130 | if (!this.reinvoke(pre_cursor) && !first_invocation) { | |
|
111 | 131 | this.close(); |
|
112 | 132 | return; |
|
113 | 133 | } |
|
114 | 134 | |
|
115 | 135 | this.autopick = false; |
|
116 | if (ff != 'undefined' && ff == true) { | |
|
136 | if (first_invocation) { | |
|
117 | 137 | this.autopick = true; |
|
118 | 138 | } |
|
119 | 139 | |
|
120 | 140 | // We want a single cursor position. |
|
121 |
if (this.editor.somethingSelected()) |
|
|
141 | if (this.editor.somethingSelected()) { | |
|
142 | return; | |
|
143 | }; | |
|
122 | 144 | |
|
123 | 145 | // one kernel completion came back, finish_completing will be called with the results |
|
124 | 146 | // we fork here and directly call finish completing if kernel is busy |
@@ -198,7 +220,9 var IPython = (function (IPython) { | |||
|
198 | 220 | this.complete = $('<div/>').addClass('completions'); |
|
199 | 221 | this.complete.attr('id', 'complete'); |
|
200 | 222 | |
|
201 | this.sel = $('<select style="width: auto"/>').attr('multiple', 'true').attr('size', Math.min(10, this.raw_result.length)); | |
|
223 | this.sel = $('<select style="width: auto"/>') | |
|
224 | .attr('multiple', 'true') | |
|
225 | .attr('size', Math.min(10, this.raw_result.length)); | |
|
202 | 226 | this.complete.append(this.sel); |
|
203 | 227 | $('body').append(this.complete); |
|
204 | 228 |
General Comments 0
You need to be logged in to leave comments.
Login now