Skip to content

Commit

Permalink
Always make sure an option's search_text gets reset when winnowing.
Browse files Browse the repository at this point in the history
This fixes an issue where group search text doesn't get reset
properly and simplifies the match functionality.
  • Loading branch information
pfiller committed Jul 16, 2013
1 parent c039885 commit 1b7cd20
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,20 @@ class AbstractChosen
unless option.group and not @group_search
option.search_match = false

search_string = if option.group then option.label else option.html
option.search_match = this.search_string_match(search_string, regex)
option.search_text = if option.group then option.label else option.html
option.search_match = this.search_string_match(option.search_text, regex)
results += 1 if option.search_match

if option.search_match
if searchText.length
startpos = search_string.search zregex
text = search_string.substr(0, startpos + searchText.length) + '</em>' + search_string.substr(startpos + searchText.length)
text = text.substr(0, startpos) + '<em>' + text.substr(startpos)
else
text = search_string

option.search_text = text
startpos = option.search_text.search zregex
text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length)
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos)

This comment has been minimized.

Copy link
@kenearley

kenearley Jul 16, 2013

It's hard to follow having the closing </em> in line 140 and the starting <em> in line 141. I know this is not part of this commit, but I guess I just noticed it now. Non-blocking. It just takes it bit more effort to grok.


@results_data[option.group_array_index].group_match = true if option.group_array_index?

else if option.group_array_index? and @results_data[option.group_array_index].search_match
option.search_match = true
option.search_text = search_string

if results < 1 and searchText.length
this.update_results_content ""
Expand Down

0 comments on commit 1b7cd20

Please sign in to comment.