Commit 7de68c8b authored by Fatih Acet's avatar Fatih Acet

Merge branch 'autocomplete-stays-open' into 'master'

Fixed GFM autocomplete regex

## What does this MR do?

Their was a bug in the regex that meant it was matching from the beginning of the GFM input text. This fixes that by splitting spaces & then checking on the last match. 

It also fixes a bug where `@#` etc. would open 2 autocomplete dropdowns.

## What are the relevant issue numbers?

Closes #25119

See merge request !7826
parents 2adc6568 34053a49
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment