javascript Ace 编辑器空格变成了制表符?

Har*_*rry 2 javascript ace-editor

我正在使用具有以下设置的 ace 编辑器:

    ace.getSession().setTabSize(2);
    ace.getSession().setUseSoftTabs(true);
    ace.getSession().setUseWrapMode(true);
Run Code Online (Sandbox Code Playgroud)

每当我按空格时,它会自动缩进 2。我只希望它在按 Tab 时缩进 2 个空格,但在按空格时缩进 1 个空格。我如何解决它?谢谢。

Jes*_*sse 6

您的代码中可能还有其他设置导致了这种情况,请考虑以下 2 个代码示例 ::

var editor = ace.edit("editor");
editor.session.setOptions({ tabSize: 2, useSoftTabs: true });
Run Code Online (Sandbox Code Playgroud)
#editor {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script>
<div id="editor"></div>
Run Code Online (Sandbox Code Playgroud)

var editor = ace.edit("editor");
editor.session.setOptions({ tabSize: 8, useSoftTabs: true });
Run Code Online (Sandbox Code Playgroud)
#editor {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script>
<div id="editor"></div>
Run Code Online (Sandbox Code Playgroud)