Autocomplete 仅当键入了正确的作用域时,才为方法启用ace编辑器自动完成
我正在使用ace编辑器为通过方法加载到ace/代码段中的自定义代码段启用自动完成。但是,我希望只有在用户输入了正确的作用域后,才能在自动完成中弹出各种代码段,这将触发所述代码段 目前,我已经在代码片段中以正则表达式的形式设置了防护,但这似乎不起作用。 guard函数是否足够有效以正确触发代码段,或者我是否必须修改ace.define函数中的某些内容Autocomplete 仅当键入了正确的作用域时,才为方法启用ace编辑器自动完成,autocomplete,ace-editor,Autocomplete,Ace Editor,我正在使用ace编辑器为通过方法加载到ace/代码段中的自定义代码段启用自动完成。但是,我希望只有在用户输入了正确的作用域后,才能在自动完成中弹出各种代码段,这将触发所述代码段 目前,我已经在代码片段中以正则表达式的形式设置了防护,但这似乎不起作用。 guard函数是否足够有效以正确触发代码段,或者我是否必须修改ace.define函数中的某些内容 var editor = ace.edit("aceTextEditorContainer"); editor.setTheme("ace
var editor = ace.edit("aceTextEditorContainer");
editor.setTheme("ace/theme/textmate");
editor.getSession().setMode("ace/mode/gameblox");
ace.require("ace/config").set("workerPath", "path/to/ace");
// editor.session.setOption("useWorker", true);
ace.require("ace/ext/language_tools");
editor.$blockScrolling = Infinity;
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
我现在有这个。
我通过以下函数加载代码段:
ace.config.loadModule("ace/snippets/gameblox", function() {
if (window.snippetArray) {
snippetManager.files.gameblox = {};
snippetManager.files.gameblox["scope"] = "gameblox";
snippetManager.files.gameblox["snippetText"] = ace.require("ace/snippets/gameblox").snippetText;
snippetManager.files.gameblox["snippets"] = [];
snippetManager.files.gameblox.snippets.concat(ace.require("ace/snippets/gameblox").snippets);
for (var i=0; i<window.snippetArray.length; i++){
var m = window.snippetArray[i].name;
if (window.snippetArray[i].arguments){
m += window.snippetArray[i].arguments;
}
var f = snippetArray[i].function;
if (window.snippetArray[i].possibleScopes){
var sGuard = snippetArray[i].possibleScopes;// + "[.]" + f;
var sScope = "scope:gameblox \n\ \n\ WWWuuuutttt \n\ snippet "+m +" \n\ "+ f+ " \n\ ";
snippetManager.files.gameblox.snippetText += sScope;
var aScope = {name:m,content:f, trigger:sGuard + "[.]" + f.split("(")[0]};//,tabTrigger:sGuard,guard:sGuard, trigger:sGuard, endTrigger:sGuard, endGuard: sGuard};
snippetManager.files.gameblox.snippets.push(aScope);
} else {
var sNoScope = "scope:gameblox \n\ \n\ WWWuuuutttt \n\ snippet "+m +" \n\ "+f + " \n\ ";
snippetManager.files.gameblox.snippetText += sNoScope;
var a = {name:m,content:f,tabTrigger:f};
snippetManager.files.gameblox.snippets.push(a);
}
}
snippetManager.register(snippetManager.files.gameblox.snippets, snippetManager.files.gameblox.scope);
}
});
ace.config.loadModule(“ace/snippets/gameblox”,function()){
if(window.snippetArray){
snippetManager.files.gameblox={};
snippetManager.files.gameblox[“scope”]=“gameblox”;
snippetManager.files.gameblox[“snippetText”]=ace.require(“ace/snippets/gameblox”).snippetText;
snippetManager.files.gameblox[“snippets”]=[];
snippetManager.files.gameblox.snippets.concat(ace.require(“ace/snippets/gameblox”).snippets);
对于(var i=0;i查看代码片段的示例,以及它们应该应用于何处的源代码将有助于更好地理解您的问题谢谢。我在问题中添加了更多信息。我希望我的问题现在更容易理解。为什么这些代码片段?它们不是只需按tab键而不按弹出键即可使用的,对吗?我想您需要d创建一个新的自动补全器,而不是按tab键时,它们会弹出并自动完成。但我只希望它们在各种情况下弹出。这不是片段的功能吗?我认为您需要添加一个新的自动补全器