2016-07-15 84 views
1

我想根據字符串更新自動填充建議。在ace編輯器中動態自動完成

aceeditorObj.completers.push({ 
     getCompletions: function(editor, session, pos, prefix, callback) { 
      obj = editor.getSession().getTokenAt(pos.row, pos.column-count); 
      if(obj.value === "student"){ 
       var wordList = ["name", "age" , "surname"]; 
       callback(null, wordList.map(function(word) { 
        return { 
         caption: word, 
         value: word, 
         meta: "static" 
        }; 
       })); 

      } 

     } 
    }); 

姓名,年齡和姓氏被添加到自動建議列表中。但舊的仍然存在。如何只顯示自動完成列表中的新世界列表?

+0

可以去除其他完成者 –

回答

0

嘗試的語言工具設置爲空白你打電話給你個完成功能之後:

var langTools = ace.require("ace/ext/language_tools"); 

    aceeditorObj.completers.push({ 
     getCompletions: function(editor, session, pos, prefix, callback) { 
      obj = editor.getSession().getTokenAt(pos.row, pos.column-count); 
      if(obj.value === "student"){ 
       var wordList = ["name", "age" , "surname"]; 
       callback(null, wordList.map(function(word) { 
        return { 
         caption: word, 
         value: word, 
         meta: "static" 
        }; 
       })); 

      } 

     } 
    }); 

    langTools.setCompleters([]); // This function should clear them