mirror of
https://github.com/yingziwu/mastodon.git
synced 2026-02-04 03:25:14 +00:00
Fix hashtag autocomplete replacing suggestion's first characters with input (#37281)
This commit is contained in:
parent
8233295e3b
commit
8d1ea4c531
1 changed files with 10 additions and 1 deletions
|
|
@ -673,7 +673,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…
Add table
Add a link
Reference in a new issue