Skip to content

Commit

Permalink
Merge pull request ivirabyan#43 from micobg/master
Browse files Browse the repository at this point in the history
Bugfix: when add the same mention more than once position is not correct
  • Loading branch information
ivirabyan committed Sep 7, 2015
2 parents e118ec9 + b2a9f26 commit 467d718
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion jquery.mentions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class MentionsInput extends MentionsBase
@input.on("resize.#{namespace}", (=> setTimeout(@_updateVScroll, 10)))

_setValue: (value) ->
offset = 0
mentionRE = /@\[([^\]]+)\]\(([^ \)]+)\)/g
@value = value.replace(mentionRE, '$1')
@input.val(@value)
Expand All @@ -220,8 +221,9 @@ class MentionsInput extends MentionsBase
@_addMention(
name: match[1],
uid: match[2],
pos: @value.indexOf(match[1])
pos: match.index - offset
)
offset += match[2].length + 5
match = mentionRE.exec(value)
@_updateValue()

Expand Down
6 changes: 4 additions & 2 deletions jquery.mentions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 467d718

Please sign in to comment.