Browse code

Don't consider numbers word separators

This made sense on paper when deciding what was a "word". However in
reality this is rarely an indication of a separate word. I've found that
this caused hexadecimal or base64 strings to be favoured in matches.

John Hawthorn authored on 27/06/2016 06:10:25
Showing 2 changed files

... ...
@@ -69,7 +69,7 @@ is able to score based on the optimal match.
69 69
 * Matches (positive score)
70 70
   * consecutive
71 71
   * following a slash
72
-  * following a space, underscore, dash, or number (the start of a word)
72
+  * following a space, underscore, or dash (the start of a word)
73 73
   * capital letter (the start of a CamelCase word)
74 74
   * following a dot (often a file extension)
75 75
 
... ...
@@ -66,8 +66,7 @@ static void precompute_bonus(const char *haystack, score_t *match_bonus) {
66 66
 		if (isalnum(ch)) {
67 67
 			if (!last_ch || last_ch == '/') {
68 68
 				score = SCORE_MATCH_SLASH;
69
-			} else if (last_ch == '-' || last_ch == '_' || last_ch == ' ' ||
70
-				   (last_ch >= '0' && last_ch <= '9')) {
69
+			} else if (last_ch == '-' || last_ch == '_' || last_ch == ' ') {
71 70
 				score = SCORE_MATCH_WORD;
72 71
 			} else if (last_ch >= 'a' && last_ch <= 'z' && ch >= 'A' && ch <= 'Z') {
73 72
 				/* CamelCase */