modules.move: slightly prioritize categories that start with the search string

master
Miikka 2018-04-25 02:25:49 +03:00 committed by GitHub
parent d6793d5c12
commit 82a89b6e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -32,6 +32,11 @@ module.exports = bot => {
if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i + 1))) break;
i++;
} while (i < normalizedSearchStr.length);
if (i > 0 && normalizedCatName.startsWith(normalizedSearchStr.slice(0, i))) {
// Slightly prioritize categories that *start* with the search string
i += 0.5;
}
return [cat, i];
});