From 34053a49703613d08bab7010a970b0ea8096ebad Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 29 Nov 2016 16:40:03 +0000 Subject: Fixed GFM autocomplete regex Without this fix it is possible that the autocomplete popup will stay open with the very first match, no matter if there is a match further in the string. Closes #25119 --- app/assets/javascripts/gfm_auto_complete.js.es6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/assets') diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6 index 89fe13b7a45..10769b7fd4f 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.es6 +++ b/app/assets/javascripts/gfm_auto_complete.js.es6 @@ -59,12 +59,13 @@ // Tweaked to commands to start without a space only if char before is a non-word character // https://github.com/ichord/At.js var _a, _y, regexp, match; + subtext = subtext.split(' ').pop(); flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); _a = decodeURI("%C3%80"); _y = decodeURI("%C3%BF"); - regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)|([^\\x00-\\xff]*)$", 'gi'); + regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "(?!\\W)([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)|([^\\x00-\\xff]*)$", 'gi'); match = regexp.exec(subtext); -- cgit v1.2.1