diff options
| author | おさむのひと <46447427+samunohito@users.noreply.github.com> | 2025-02-26 10:51:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-26 01:51:23 +0000 |
| commit | d87488a5f054a60632f0c484c84b0c10319946dd (patch) | |
| tree | c95d848f0f6bd54dca28c311d11d2d67387890ad /packages/frontend/src/scripts | |
| parent | fix(backend): カスタム絵文字の一括インポートをした時にHTT... (diff) | |
| download | sharkey-d87488a5f054a60632f0c484c84b0c10319946dd.tar.gz sharkey-d87488a5f054a60632f0c484c84b0c10319946dd.tar.bz2 sharkey-d87488a5f054a60632f0c484c84b0c10319946dd.zip | |
fix(frontend): ユーザのサジェスト中に@を入力してもサジェスト結果が消えないように (#15435)
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/autocomplete.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/frontend/src/scripts/autocomplete.ts b/packages/frontend/src/scripts/autocomplete.ts index 55015c90fd..9a603b848c 100644 --- a/packages/frontend/src/scripts/autocomplete.ts +++ b/packages/frontend/src/scripts/autocomplete.ts @@ -4,9 +4,9 @@ */ import { nextTick, ref, defineAsyncComponent } from 'vue'; -import type { Ref } from 'vue'; import getCaretCoordinates from 'textarea-caret'; import { toASCII } from 'punycode.js'; +import type { Ref } from 'vue'; import { popup } from '@/os.js'; export type SuggestionType = 'user' | 'hashtag' | 'emoji' | 'mfmTag' | 'mfmParam'; @@ -98,15 +98,21 @@ export class Autocomplete { const isMention = mentionIndex !== -1; const isHashtag = hashtagIndex !== -1; - const isMfmParam = mfmParamIndex !== -1 && afterLastMfmParam?.includes('.') && !afterLastMfmParam?.includes(' '); + const isMfmParam = mfmParamIndex !== -1 && afterLastMfmParam?.includes('.') && !afterLastMfmParam.includes(' '); const isMfmTag = mfmTagIndex !== -1 && !isMfmParam; const isEmoji = emojiIndex !== -1 && text.split(/:[a-z0-9_+\-]+:/).pop()!.includes(':'); let opened = false; if (isMention && this.onlyType.includes('user')) { - const username = text.substring(mentionIndex + 1); - if (username !== '' && username.match(/^[a-zA-Z0-9_]+$/)) { + // ユーザのサジェスト中に@を入力すると、その位置から新たにユーザ名を取りなおそうとしてしまう + // この動きはリモートユーザのサジェストを阻害するので、@を検知したらその位置よりも前の@を探し、 + // ホスト名を含むリモートのユーザ名を全て拾えるようにする + const mentionIndexAlt = text.lastIndexOf('@', mentionIndex - 1); + const username = mentionIndexAlt === -1 + ? text.substring(mentionIndex + 1) + : text.substring(mentionIndexAlt + 1); + if (username !== '' && username.match(/^[a-zA-Z0-9_@.]+$/)) { this.open('user', username); opened = true; } else if (username === '') { |