summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/autocomplete.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/frontend/src/scripts/autocomplete.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/packages/frontend/src/scripts/autocomplete.ts b/packages/frontend/src/scripts/autocomplete.ts
index 7766c44c04..9a603b848c 100644
--- a/packages/frontend/src/scripts/autocomplete.ts
+++ b/packages/frontend/src/scripts/autocomplete.ts
@@ -3,9 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-import { nextTick, Ref, ref, defineAsyncComponent } from 'vue';
+import { nextTick, ref, defineAsyncComponent } 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';
@@ -97,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 === '') {