diff options
| author | Stephen Blott | 2012-11-04 08:26:06 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2012-11-04 08:26:06 +0000 | 
| commit | e5aa0993b7353b16308f7dbfd0a1e217264c2cae (patch) | |
| tree | d8d37f4ee068c54506aa8e878b53cecf6cec96b8 /background_scripts | |
| parent | e97990e479989bd05f9d6377cfb327fccdcc1ed9 (diff) | |
| download | vimium-e5aa0993b7353b16308f7dbfd0a1e217264c2cae.tar.bz2 | |
Highlight all matches, not just the first.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 11 | 
1 files changed, 9 insertions, 2 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 9314d9be..c8a06b27 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -50,8 +50,15 @@ class Suggestion    highlightTerms: (string) ->      ranges = []      for term in @queryTerms -      i = string.search(RegexpCache.get(term)) -      ranges.push([i, i + term.length]) if i >= 0 +      textPosition = 0 +      splits = string.split(RegexpCache.get(term, "(", ")")).reverse() +      while 0 < splits.length +        unmatchedText = splits.pop() +        textPosition += unmatchedText.length +        matchedText = if 0 < splits.length then splits.pop() else null +        if matchedText +          ranges.push([textPosition, textPosition + matchedText.length]) +          textPosition += matchedText.length      return string if ranges.length == 0  | 
