diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-13 02:16:36 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-13 02:16:36 +0300 |
commit | 5d4993d62357e438b6211247278025040f3ae382 (patch) | |
tree | b1deb16193509678655274b532ad8cfa8674e364 | |
parent | f393f2dde016edf63b5168eb63405f15d65803eb (diff) |
Only autocomplete commands at the beginning of a line
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js.es6 | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6 index 9be32ed5937..2e1cbb362a3 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.es6 +++ b/app/assets/javascripts/gfm_auto_complete.js.es6 @@ -268,7 +268,7 @@ return _.template(tpl)(value); }, insertTpl: function(value) { - var tpl = "\n/${name} "; + var tpl = "/${name} "; var reference_prefix = null; if (value.params.length > 0) { reference_prefix = value.params[0][0]; @@ -282,7 +282,16 @@ callbacks: { sorter: this.DefaultOptions.sorter, filter: this.DefaultOptions.filter, - beforeInsert: this.DefaultOptions.beforeInsert + beforeInsert: this.DefaultOptions.beforeInsert, + matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) { + var regexp = /(?:^|\n)\/([A-Za-z_]*)$/gi + var match = regexp.exec(subtext); + if (match) { + return match[1]; + } else { + return null; + } + } } }); return; |