mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #3858 from tgxworld/exclude_letter_character_class
UX: Trigger autocompleter only for specific characters.
This commit is contained in:
commit
bec1606328
1 changed files with 4 additions and 2 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
export var CANCELLED_STATUS = "__CANCELLED";
|
||||
|
||||
const allowedLettersRegex = /[\s\t\[\{\(]/;
|
||||
|
||||
var keys = {
|
||||
backSpace: 8,
|
||||
tab: 9,
|
||||
|
@ -287,7 +289,7 @@ export default function(options) {
|
|||
if (options.key && e.which === options.key.charCodeAt(0)) {
|
||||
caretPosition = Discourse.Utilities.caretPosition(me[0]);
|
||||
var prevChar = me.val().charAt(caretPosition - 1);
|
||||
if (!prevChar || /[^\w\)\]]/.test(prevChar)) {
|
||||
if (!prevChar || allowedLettersRegex.test(prevChar)) {
|
||||
completeStart = completeEnd = caretPosition;
|
||||
updateAutoComplete(options.dataSource(""));
|
||||
}
|
||||
|
@ -341,7 +343,7 @@ export default function(options) {
|
|||
stopFound = prev === options.key;
|
||||
if (stopFound) {
|
||||
prev = me[0].value[c - 1];
|
||||
if (!prev || /[^\w\)\]]/.test(prev)) {
|
||||
if (!prev || allowedLettersRegex.test(prev)) {
|
||||
completeStart = c;
|
||||
caretPosition = completeEnd = initial;
|
||||
term = me[0].value.substring(c + 1, initial);
|
||||
|
|
Loading…
Reference in a new issue