Unified · Split
| @@ -135,6 +135,7 @@ class app.Searcher · 134 unmodified lines | ||
| 135 | 135 | # |
| 136 | 136 | |
| 137 | 137 | index = # position of the query in the string being matched |
| 138 | + lastIndex = # last position of the query in the string being matched | |
| 138 | 139 | match = # regexp match data |
| 139 | 140 | score = # score for the current match |
| 140 | 141 | separators = # counter |
| @@ -144,6 +145,14 @@ class app.Searcher · 3 unmodified lines | ||
| 144 | 145 | index = value.indexOf @query |
| 145 | 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 | 156 | # Remove one point for each unmatched character. |
| 148 | 157 | score = 100 - (value.length - @queryLength) |
| 149 | 158 | |