From 7427825790daff2ee6d6b1db8c7ea73c29f7f7bc Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 24 Jan 2017 09:31:31 +0100 Subject: [PATCH] [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 --- addons/mail/static/src/js/composer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 6560e76fb13..21a4124ee54 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -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