如何防止Ace编辑器在输入时自动完成?

How do I prevent Ace Editor from auto-completing as I type?

本文关键字:输入 何防止 Ace 编辑器      更新时间:2023-09-26

我希望建议只在使用Cntrl-Spacebar时显示。

您需要设置以下变量:

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>