在键入时如何防止Ace Editor自动完成?

时间:2015-07-08 16:53:26

标签: javascript autocomplete ace-editor

我希望该建议仅在我使用Cntrl-Spacebar时显示。他们的文档有点缺乏。

1 个答案:

答案 0 :(得分:2)

您需要设置以下变量:

enableBasicAutocompletion:true
enableLiveAutocompletion:false

仅在按Cntrl - Spacebar时才能实现自动完成。

选中此代码段进行实时演示:

  var langTools = ace.require("ace/ext/language_tools");
  var editor = ace.edit("editor");
  editor.setOptions({
    enableBasicAutocompletion: true,
    enableLiveAutocompletion: false
  });
<html>

<body>
  <div id="editor" style="height: 500px; width: 800px">Type in a word like "will" below and press ctrl+space to get "auto completion"</div>
  <div id="commandline" style="position: absolute; bottom: 10px; height: 20px; width: 800px;"></div>
</body>
<script src="https://rawgithub.com/ajaxorg/ace-builds/master/src/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="https://rawgithub.com/ajaxorg/ace-builds/master/src/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>

</html>