mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-13 02:36:36 -05:00
Fix autosuggestions overstaying their welcome in languages that don't use spaces (#40217)
This commit is contained in:
@@ -6,6 +6,14 @@ describe('textAtCursorMatchesToken', () => {
|
||||
['#hashtag', 7, ['#']],
|
||||
[1, '#hashtag'],
|
||||
],
|
||||
[
|
||||
['@alice', 6, ['@']],
|
||||
[1, '@alice'],
|
||||
],
|
||||
[
|
||||
['@alice', 6, ['@']],
|
||||
[1, '@alice'],
|
||||
],
|
||||
[
|
||||
['#hash tag', 8, ['#']],
|
||||
[1, '#hash tag'],
|
||||
@@ -24,7 +32,35 @@ describe('textAtCursorMatchesToken', () => {
|
||||
],
|
||||
[
|
||||
['#ハッシュ タグ', 7, ['#']],
|
||||
[1, '#ハッシュ タグ'],
|
||||
[null, null],
|
||||
],
|
||||
[
|
||||
['@alice reply', 12, ['@']],
|
||||
[1, '@alice reply'],
|
||||
],
|
||||
[
|
||||
['@alice 这是我输入的回复内容', 17, ['@']],
|
||||
[null, null],
|
||||
],
|
||||
[
|
||||
['@alice これは本文', 12, ['@']],
|
||||
[null, null],
|
||||
],
|
||||
[
|
||||
['@alice 이것은답변입니다', 15, ['@']],
|
||||
[null, null],
|
||||
],
|
||||
[
|
||||
['@alice これは本文', 12, ['@']],
|
||||
[null, null],
|
||||
],
|
||||
[
|
||||
['@алиса', 6, ['@']],
|
||||
[1, '@алиса'],
|
||||
],
|
||||
[
|
||||
['@алиса пример', 13, ['@']],
|
||||
[1, '@алиса пример'],
|
||||
],
|
||||
] as const)(
|
||||
'textAtCursorMatchesToken(%s) is %o',
|
||||
|
||||
@@ -8,7 +8,7 @@ export const textAtCursorMatchesToken = (
|
||||
let word: string;
|
||||
|
||||
const regex = new RegExp(
|
||||
`[${searchTokens.join('')}${WORD}+-]+(\\s[${WORD}]+)?$`,
|
||||
`[${searchTokens.join('')}${WORD}+-]+(\\s[\\p{Script=Latin}\\p{Script=Cyrillic}\\p{M}]+)?$`,
|
||||
'iu',
|
||||
);
|
||||
const left = str.slice(0, caretPosition).search(regex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const HASHTAG_SEPARATORS = '_\\u00b7\\u200c';
|
||||
const ALPHA = '\\p{L}\\p{M}';
|
||||
export const ALPHA = '\\p{L}\\p{M}';
|
||||
export const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}';
|
||||
|
||||
const buildHashtagPatternRegex = () => {
|
||||
|
||||
Reference in New Issue
Block a user