1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-08 23:30:53 +00:00

- Added option to revert to old behavior which only considers matches at the start of the emote and at capitalized sections.

This commit is contained in:
OMGparticles 2023-04-22 21:26:42 -07:00
parent efd0b259a3
commit 08e0ea38a1

View file

@ -151,6 +151,16 @@ export default class Input extends Module {
} }
}); });
this.settings.add('chat.tab-complete.prefix-and-capitals-only', {
default: false,
ui: {
path: 'Chat > Input >> Tab Completion',
title: 'Only match emotes at start or at capitalized sections.',
description: 'Will only suggest emotes if the term resides at the start of the emote, or at a capital letter.',
component: 'setting-check-box'
}
});
// Components // Components
@ -1030,9 +1040,12 @@ export default class Input extends Module {
search = input.startsWith(':') ? input.slice(1) : input; search = input.startsWith(':') ? input.slice(1) : input;
const only_match_starts = this.chat.context.get('chat.tab-complete.prefix-and-capitals-only');
for(const emote of emotes) { for(const emote of emotes) {
const match_type = inst.doesEmoteMatchTerm(emote, search); const match_type = inst.doesEmoteMatchTerm(emote, search);
if ( match_type !== NO_MATCH ) { const valid_match = only_match_starts ? match_type > SUBSTRING_MATCH : match_type !== NO_MATCH;
if ( valid_match ) {
const element = { const element = {
current: input, current: input,
emote, emote,
@ -1080,8 +1093,13 @@ export default class Input extends Module {
const included = new Set; const included = new Set;
for(const name in this.emoji.names) const only_match_starts = this.chat.context.get('chat.tab-complete.prefix-and-capitals-only');
if ( has_colon ? name === search : name.startsWith(search) ) {
for(const name in this.emoji.names) {
const valid_match = has_colon && name === search ||
only_match_starts && name.startsWith(search) ||
! only_match_starts && name.includes(search);
if ( valid_match ) {
const emoji = this.emoji.emoji[this.emoji.names[name]], const emoji = this.emoji.emoji[this.emoji.names[name]],
toned = emoji.variants && emoji.variants[tone], toned = emoji.variants && emoji.variants[tone],
source = toned || emoji; source = toned || emoji;
@ -1110,6 +1128,7 @@ export default class Input extends Module {
}); });
} }
} }
}
return results; return results;
} }
@ -1193,9 +1212,12 @@ export default class Input extends Module {
const search = input.startsWith(':') ? input.slice(1) : input, const search = input.startsWith(':') ? input.slice(1) : input,
results = []; results = [];
const only_match_starts = this.chat.context.get('chat.tab-complete.prefix-and-capitals-only');
for(const emote of emotes) { for(const emote of emotes) {
const match_type = inst.doesEmoteMatchTerm(emote, search) const match_type = inst.doesEmoteMatchTerm(emote, search);
if ( match_type !== NO_MATCH ) const valid_match = only_match_starts ? match_type > SUBSTRING_MATCH : match_type !== NO_MATCH;
if ( valid_match )
results.push({ results.push({
current: input, current: input,
emote, emote,