File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,13 @@ $.widget( "ui.autocomplete", {
208
208
} ,
209
209
210
210
_getValue : function ( value ) {
211
+ //find the caret
211
212
this . caretPos = this . element [ 0 ] . selectionStart ;
213
+ /*
214
+ * cut the string in half at the carot, split at the separators,
215
+ * and then concat the outter array values so that editing the
216
+ * middle of a string still correctly triggers the autocomplete
217
+ */
212
218
var begin = value . substr ( 0 , this . caretPos ) . split ( this . options . separator ) ,
213
219
end = value . substr ( this . caretPos ) . split ( this . options . separator ) ;
214
220
return begin [ begin . length - 1 ] + end [ 0 ] ;
@@ -218,8 +224,11 @@ $.widget( "ui.autocomplete", {
218
224
var begin = this . term . substr ( 0 , this . caretPos ) . split ( this . options . separator ) ,
219
225
end = this . term . substr ( this . caretPos ) . split ( this . options . separator ) ,
220
226
result = '' ;
227
+
228
+ //clean the arrays of empty entries
221
229
begin . pop ( ) ;
222
230
end . shift ( ) ;
231
+
223
232
if ( begin . length ) {
224
233
result = begin . join ( this . options . separator ) + this . options . separator ;
225
234
}
You can’t perform that action at this time.
0 commit comments