From f1bbbcfedf950d2bfd391834a19e6bfad530dd27 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Jul 2018 00:51:30 +0900 Subject: [PATCH] Fix #1960 --- src/client/app/common/views/directives/autocomplete.ts | 7 +++++-- src/misc/acct/render.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/app/common/views/directives/autocomplete.ts b/src/client/app/common/views/directives/autocomplete.ts index bb97bc288..10c37a06e 100644 --- a/src/client/app/common/views/directives/autocomplete.ts +++ b/src/client/app/common/views/directives/autocomplete.ts @@ -1,5 +1,6 @@ import * as getCaretCoordinates from 'textarea-caret'; import MkAutocomplete from '../components/autocomplete.vue'; +import renderAcct from '../../../../../misc/acct/render'; export default { bind(el, binding, vn) { @@ -187,13 +188,15 @@ class Autocomplete { const trimmedBefore = before.substring(0, before.lastIndexOf('@')); const after = source.substr(caret); + const acct = renderAcct(value); + // 挿入 - this.text = trimmedBefore + '@' + value.username + ' ' + after; + this.text = trimmedBefore + '@' + acct + ' ' + after; // キャレットを戻す this.vm.$nextTick(() => { this.textarea.focus(); - const pos = trimmedBefore.length + (value.username.length + 2); + const pos = trimmedBefore.length + (acct.length + 2); this.textarea.setSelectionRange(pos, pos); }); } else if (type == 'hashtag') { diff --git a/src/misc/acct/render.ts b/src/misc/acct/render.ts index 20031883d..92ee2010a 100644 --- a/src/misc/acct/render.ts +++ b/src/misc/acct/render.ts @@ -1,5 +1,8 @@ -import { IUser } from '../../models/user'; +type UserLike = { + host: string; + username: string; +}; -export default (user: IUser) => { +export default (user: UserLike) => { return user.host === null ? user.username : `${user.username}@${user.host}`; };