简体   繁体   English

设置Ace编辑器的值时保留缩进

[英]Preserve indentation when setting value of Ace editor

How can you preserve the indentation of a string that is push into Ace editor by .setValue() ? 如何保留由.setValue()推送到Ace编辑器中的字符串的缩进? Now, when I push a string into the editor, all the indentation is lost and it has this weird typewriter spacing: assuming the typewriter is | 现在,当我将字符串推入编辑器时,所有的缩进都会丢失,并且它具有奇怪的打字机间距:假定打字机是| if 如果

string to edit here with four space->    |

if I press backspace,: 如果按退格键:

string to edit here with four space-   |

I dont know why this happen, please help 我不知道为什么会这样,请帮忙

Looks like Ace calculates wrong cursor position. 看起来像Ace计算错误的光标位置。
This can happen either if your editor have non monospace font. 如果您的编辑器具有非等宽字体,则可能会发生这种情况。
Or because of this bug if you are using Safari on Mac OS X 10.8 或者由于此错误(如果您在Mac OS X 10.8上使用Safari)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM