mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-16 10:06:54 +00:00
Fix tab-completion sorting (#617)
This commit is contained in:
parent
86b0b624f7
commit
92f5b7f2c9
1 changed files with 15 additions and 5 deletions
|
@ -175,7 +175,6 @@ export default class Input extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
|
||||||
overrideMentionMatcher(inst) {
|
overrideMentionMatcher(inst) {
|
||||||
if ( inst._ffz_override )
|
if ( inst._ffz_override )
|
||||||
return;
|
return;
|
||||||
|
@ -259,22 +258,33 @@ export default class Input extends Module {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const results = [];
|
const startingResults = [], otherResults = [];
|
||||||
const search = input.startsWith(':') ? input.slice(1) : input;
|
const search = input.startsWith(':') ? input.slice(1) : input;
|
||||||
for (const set of hydratedEmotes) {
|
for (const set of hydratedEmotes) {
|
||||||
if (set && Array.isArray(set.emotes)) {
|
if (set && Array.isArray(set.emotes)) {
|
||||||
for (const emote of set.emotes) {
|
for (const emote of set.emotes) {
|
||||||
if (inst.doesEmoteMatchTerm(emote, search)) {
|
if (inst.doesEmoteMatchTerm(emote, search)) {
|
||||||
results.push({
|
const element = {
|
||||||
current: input,
|
current: input,
|
||||||
replacement: emote.token,
|
replacement: emote.token,
|
||||||
element: inst.renderEmoteSuggestion(emote)
|
element: inst.renderEmoteSuggestion(emote)
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (emote.token.toLowerCase().startsWith(search)) {
|
||||||
|
startingResults.push(element);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
otherResults.push(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
}
|
||||||
|
|
||||||
|
startingResults.sort((a, b) => a.replacement < b.replacement ? -1 : a.replacement > b.replacement ? 1 : 0);
|
||||||
|
otherResults.sort((a, b) => a.replacement < b.replacement ? -1 : a.replacement > b.replacement ? 1 : 0);
|
||||||
|
|
||||||
|
return startingResults.concat(otherResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue