[Glitch] Fix hashtag autocomplete replacing suggestion's first characters with input
Port d6a40c2891770d2bd5dfa881d482a34c4acd646f to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
84feffd6e6
commit
22724d2367
@ -709,7 +709,16 @@ export function selectComposeSuggestion(position, token, suggestion, path) {
|
|||||||
|
|
||||||
dispatch(useEmoji(suggestion));
|
dispatch(useEmoji(suggestion));
|
||||||
} else if (suggestion.type === 'hashtag') {
|
} else if (suggestion.type === 'hashtag') {
|
||||||
completion = token + suggestion.name.slice(token.length - 1);
|
// TODO: it could make sense to keep the “most capitalized” of the two
|
||||||
|
const tokenName = token.slice(1); // strip leading '#'
|
||||||
|
const suggestionPrefix = suggestion.name.slice(0, tokenName.length);
|
||||||
|
const prefixMatchesSuggestion = suggestionPrefix.localeCompare(tokenName, undefined, { sensitivity: 'accent' }) === 0;
|
||||||
|
if (prefixMatchesSuggestion) {
|
||||||
|
completion = token + suggestion.name.slice(tokenName.length);
|
||||||
|
} else {
|
||||||
|
completion = `${token.slice(0, 1)}${suggestion.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
startPosition = position - 1;
|
startPosition = position - 1;
|
||||||
} else if (suggestion.type === 'account') {
|
} else if (suggestion.type === 'account') {
|
||||||
completion = `@${getState().getIn(['accounts', suggestion.id, 'acct'])}`;
|
completion = `@${getState().getIn(['accounts', suggestion.id, 'acct'])}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user