@@ -46,41 +46,6 @@ acp.initLang = (lang) => {
46
46
47
47
}
48
48
49
- acp . lang . css . init = ( ) => {
50
-
51
- let CSSProps = [ ] ;
52
-
53
- CSSProps = Array . from ( window . getComputedStyle ( document . documentElement ) ) ;
54
-
55
- CSSProps . push ( 'padding' ) ;
56
- CSSProps . push ( 'margin' ) ;
57
- CSSProps . push ( 'border' ) ;
58
- CSSProps . push ( 'flex' ) ;
59
- CSSProps . push ( 'grid' ) ;
60
- CSSProps . push ( 'gap' ) ;
61
- CSSProps . push ( 'background' ) ;
62
- CSSProps . push ( 'overflow' ) ;
63
- CSSProps . push ( 'transition' ) ;
64
- CSSProps . push ( 'animation' ) ;
65
- CSSProps . push ( '-webkit-user-select' ) ;
66
-
67
- acp . lang . css . props = CSSProps ;
68
-
69
- }
70
-
71
- acp . lang . js . init = ( ) => {
72
-
73
- const iframe = document . createElement ( 'iframe' ) ;
74
-
75
- body . append ( iframe ) ;
76
-
77
- acp . lang . js . props = iframe . contentWindow ;
78
-
79
- }
80
-
81
- // add language alias / temp @@
82
- acp . lang . javascript = acp . lang . js ;
83
-
84
49
85
50
86
51
acp . autocomplete = async ( lang ) => {
@@ -105,9 +70,22 @@ acp.autocomplete = async (lang) => {
105
70
const textBeforeCursor = acp . el . input . beforeCursor ( ) ;
106
71
let query = acp . utils . getQuery ( textBeforeCursor ) ;
107
72
73
+
74
+ // process query
75
+
76
+ const rawQuery = query ;
77
+
78
+ if ( langAcp . processQuery ) {
79
+
80
+ query = langAcp . processQuery ( query ) ;
81
+
82
+ }
83
+
84
+
108
85
// if query didn't change, return
109
86
if ( query === acp . curr . query ) return ;
110
87
88
+ // update query
111
89
acp . curr . query = query ;
112
90
113
91
@@ -117,9 +95,7 @@ acp.autocomplete = async (lang) => {
117
95
if ( query !== '' ) {
118
96
119
97
// autocomplete query
120
- results = acp . lang [ lang ] . autocomplete ( query ) ;
121
-
122
- query = acp . curr . query ;
98
+ results = acp . lang [ lang ] . autocomplete ( query , rawQuery ) ;
123
99
124
100
}
125
101
@@ -183,6 +159,7 @@ acp.autocomplete = async (lang) => {
183
159
}
184
160
185
161
162
+
186
163
/*
187
164
* Autocomplete Language Extension (acp language)
188
165
* ----------------------------------------------
@@ -226,6 +203,30 @@ acp.autocomplete = async (lang) => {
226
203
*/
227
204
228
205
206
+
207
+ acp . lang . css . init = ( ) => {
208
+
209
+ let CSSProps = [ ] ;
210
+
211
+ CSSProps = Array . from ( window . getComputedStyle ( document . documentElement ) ) ;
212
+
213
+ CSSProps . push ( 'padding' ) ;
214
+ CSSProps . push ( 'margin' ) ;
215
+ CSSProps . push ( 'border' ) ;
216
+ CSSProps . push ( 'flex' ) ;
217
+ CSSProps . push ( 'grid' ) ;
218
+ CSSProps . push ( 'gap' ) ;
219
+ CSSProps . push ( 'background' ) ;
220
+ CSSProps . push ( 'overflow' ) ;
221
+ CSSProps . push ( 'transition' ) ;
222
+ CSSProps . push ( 'animation' ) ;
223
+ CSSProps . push ( '-webkit-user-select' ) ;
224
+
225
+ acp . lang . css . props = CSSProps ;
226
+
227
+ }
228
+
229
+
229
230
acp . lang . css . autocomplete = ( query ) => {
230
231
231
232
let results = [ ] ;
@@ -252,19 +253,43 @@ acp.lang.css.autocomplete = (query) => {
252
253
}
253
254
254
255
255
- acp . lang . js . autocomplete = ( query ) => {
256
256
257
- let results = [ ] ;
257
+ acp . lang . js . init = ( ) => {
258
+
259
+ const iframe = document . createElement ( 'iframe' ) ;
260
+
261
+ body . append ( iframe ) ;
262
+
263
+ acp . lang . js . props = iframe . contentWindow ;
264
+
265
+ }
266
+
267
+ // add language alias / temp @@
268
+ acp . lang . javascript = acp . lang . js ;
269
+
258
270
271
+ acp . lang . js . processQuery = ( query ) => {
272
+
259
273
// if query dosen't include a '.', return
260
- if ( ! query . includes ( '.' ) ) return [ ] ;
274
+ if ( ! query . includes ( '.' ) ) return '' ;
261
275
262
276
// split query to get hierarchy
263
- hierarchy = query . split ( '.' ) ;
277
+ let hierarchy = query . split ( '.' ) ;
264
278
265
- // update query
266
- acp . curr . query = hierarchy [ hierarchy . length - 1 ] ;
267
- query = acp . curr . query ;
279
+ // update query to last item in hierarchy
280
+ const pQuery = hierarchy [ hierarchy . length - 1 ] ;
281
+
282
+ return pQuery ;
283
+
284
+ }
285
+
286
+
287
+ acp . lang . js . autocomplete = ( query , rawQuery ) => {
288
+
289
+ let results = [ ] ;
290
+
291
+ // split query to get hierarchy
292
+ let hierarchy = rawQuery . split ( '.' ) ;
268
293
269
294
// remove query from hierarchy
270
295
hierarchy . pop ( ) ;
0 commit comments