Unified · Split
| @@ -135,6 +135,7 @@ class app.Searcher · 134 unmodified lines | |||
| 135 | # | 135 | # |
| 136 | 136 | ||
| 137 | index = # position of the query in the string being matched | 137 | index = # position of the query in the string being matched |
| 138 | lastIndex = # last position of the query in the string being matched | ||
| 138 | match = # regexp match data | 139 | match = # regexp match data |
| 139 | score = # score for the current match | 140 | score = # score for the current match |
| 140 | separators = # counter | 141 | separators = # counter |
| @@ -144,6 +145,14 @@ class app.Searcher · 3 unmodified lines | |||
| 144 | index = value.indexOf @query | 145 | index = value.indexOf @query |
| 145 | return unless index >= 0 | 146 | return unless index >= 0 |
| 146 | 147 | ||
| 148 | lastIndex = value.lastIndexOf @query | ||
| 149 | |||
| 150 | if index isnt lastIndex | ||
| 151 | Math.max(@scoreExactMatch(value, index), @scoreExactMatch(value, lastIndex)) | ||
| 152 | else | ||
| 153 | @scoreExactMatch(value, index) | ||
| 154 | |||
| 155 | scoreExactMatch: (value, index) -> | ||
| 147 | # Remove one point for each unmatched character. | 156 | # Remove one point for each unmatched character. |
| 148 | score = 100 - (value.length - @queryLength) | 157 | score = 100 - (value.length - @queryLength) |
| 149 | 158 | ||