[FIX] mail: don't linkify removed mention

If after inserting a mention (eg: `@Guy`) and we eg. backspace and
change it (eg: to `@GuyFawkes`) the `@Guy` mention will still be
linkified but the partner is not subscribed.

This happened because the linkifying was not requiring a space to follow
the mention, but when getting the used mentions (and commands, ...) in
the message they were required (unless the mention was exactly at the
end of the message).

With this commit, a space is always required after a mention for it to
be working.

opw-705267
This commit is contained in:
Nicolas Lempereur
2017-01-25 15:47:30 +01:00
parent 6a7db30508
commit 7427825790
+2 -2
View File
@@ -130,7 +130,7 @@ var MentionManager = Widget.extend({
get_listener_selection: function (delimiter) {
var listener = _.findWhere(this.listeners, {delimiter: delimiter});
if (listener) {
var input_mentions = this.composer.$input.val().match(new RegExp(delimiter+'[^ ]+', 'g'));
var input_mentions = this.composer.$input.val().match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
return this._validate_selection(listener.selection, input_mentions);
}
return [];
@@ -270,7 +270,7 @@ var MentionManager = Widget.extend({
// create the regex of all mention's names
var names = _.pluck(listener.selection, 'name');
var escaped_names = _.map(names, function (str) {
return "("+_.str.escapeRegExp(listener.delimiter+str)+")";
return "("+_.str.escapeRegExp(listener.delimiter+str)+")(?= | )";
});
var regex_str = escaped_names.join('|');
// extract matches