From a13b4544d41717e2c7800ca8313c1129ccf327bb Mon Sep 17 00:00:00 2001 From: mrAceT Date: Thu, 29 Jul 2021 10:00:35 +0200 Subject: [PATCH] Update chosen.jquery.js --- chosen.jquery.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chosen.jquery.js b/chosen.jquery.js index dbc3a25..ca91dac 100644 --- a/chosen.jquery.js +++ b/chosen.jquery.js @@ -122,6 +122,7 @@ this.disable_search_threshold = this.options.disable_search_threshold || 0; this.disable_search = this.options.disable_search || false; this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true; + this.enable_multi_word_search = this.options.enable_multi_word_search != null ? this.options.enable_multi_word_search : true; this.group_search = this.options.group_search != null ? this.options.group_search : true; this.search_contains = this.options.search_contains || false; this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true; @@ -368,8 +369,8 @@ if (query.length) { startpos = search_match.index; prefix = text.slice(0, startpos); - fix = text.slice(startpos, startpos + query.length); - suffix = text.slice(startpos + query.length); + fix = text.slice(startpos, startpos + search_match[0].length); + suffix = text.slice(startpos + search_match[0].length); option.highlighted_html = (this.escape_html(prefix)) + "" + (this.escape_html(fix)) + "" + (this.escape_html(suffix)); } if (results_group != null) { @@ -399,6 +400,9 @@ if (!(this.enable_split_word_search || this.search_contains)) { regex_string = "^" + regex_string; } + if (this.enable_multi_word_search) { + regex_string = regex_string.replace(/\\? /,'.*?'); + } regex_flag = this.case_sensitive_search ? "" : "i"; return new RegExp(regex_string, regex_flag); };