使用“-”(破折号或减号运算符)后,ace 编辑器自动完成器不会显示。但完成器会显示其他常见运算符的建议,例如 + 、 - 、 * 。/
最佳答案
您可以覆盖默认行为
var ID_REGEX =/[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;
在 ext-language_tools.js(旧版本中)或 autocomplete/utils.js 中定义。
从下面的代码中您可以看到每个完成器都可以有自己的由identifierRegexps(字符串)提供的正则表达式:
exports.getCompletionPrefix = function (editor) {
var pos = editor.getCursorPosition();
var line = editor.session.getLine(pos.row);
var prefix;
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
completer.identifierRegexps.forEach(function(identifierRegex) {
if (!prefix && identifierRegex)
prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
}.bind(this));
}
}.bind(this));
return prefix || this.retrievePrecedingIdentifier(line, pos.column);
};
根据我的测试,我可以说这不能正常工作,因为如果前缀为空,将使用默认的正则表达式:
return prefix || this.retrievePrecedingIdentifier(line, pos.column);
此外,我在 github 页面上发现了一个具有相同问题的拉取请求: https://github.com/ajaxorg/ace/pull/2905
我还在 ace 编辑器的 github 页面上创建了一个问题: https://github.com/ajaxorg/ace/issues/3430
更新(2018 年 4 月 3 日):
看来这个功能终于进入了项目:
https://github.com/ajaxorg/ace/pull/2905#pullrequestreview-108526630
关于javascript - 当我们输入 "-"时,编辑器的自动完成功能不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42121488/