diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-07-28 07:38:29 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-07-28 07:38:29 +0900 |
| commit | 50a6efd5687d74bf9024021c06d73ad39421e163 (patch) | |
| tree | 0537bed9b3ef812b62b2cb76be9aa3b13ce85007 | |
| parent | 管理者用パスワードリセットコマンドを実装 (diff) | |
| download | misskey-50a6efd5687d74bf9024021c06d73ad39421e163.tar.gz misskey-50a6efd5687d74bf9024021c06d73ad39421e163.tar.bz2 misskey-50a6efd5687d74bf9024021c06d73ad39421e163.zip | |
Fix #2000
Diffstat (limited to '')
| -rw-r--r-- | src/client/app/common/views/directives/autocomplete.ts | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/client/app/common/views/directives/autocomplete.ts b/src/client/app/common/views/directives/autocomplete.ts index 10c37a06e7..b252cf5c1f 100644 --- a/src/client/app/common/views/directives/autocomplete.ts +++ b/src/client/app/common/views/directives/autocomplete.ts @@ -69,25 +69,25 @@ class Autocomplete { */ private onInput() { const caretPos = this.textarea.selectionStart; - const text = this.text.substr(0, caretPos); + const text = this.text.substr(0, caretPos).split('\n').pop(); const mentionIndex = text.lastIndexOf('@'); const hashtagIndex = text.lastIndexOf('#'); const emojiIndex = text.lastIndexOf(':'); - const start = Math.min( - mentionIndex == -1 ? Infinity : mentionIndex, - hashtagIndex == -1 ? Infinity : hashtagIndex, - emojiIndex == -1 ? Infinity : emojiIndex); + const max = Math.max( + mentionIndex, + hashtagIndex, + emojiIndex); - if (start == Infinity) { + if (max == -1) { this.close(); return; } - const isMention = mentionIndex == start; - const isHashtag = hashtagIndex == start; - const isEmoji = emojiIndex == start; + const isMention = mentionIndex != -1; + const isHashtag = hashtagIndex != -1; + const isEmoji = emojiIndex != -1; let opened = false; @@ -99,15 +99,15 @@ class Autocomplete { } } - if (isHashtag || opened == false) { + if (isHashtag && opened == false) { const hashtag = text.substr(hashtagIndex + 1); - if (!hashtag.includes(' ') && !hashtag.includes('\n')) { + if (!hashtag.includes(' ')) { this.open('hashtag', hashtag); opened = true; } } - if (isEmoji || opened == false) { + if (isEmoji && opened == false) { const emoji = text.substr(emojiIndex + 1); if (emoji != '' && emoji.match(/^[\+\-a-z0-9_]+$/)) { this.open('emoji', emoji); |