ace 编辑器光标行为不正确 [英] ace editor cursor behaves incorrectly

查看:89
本文介绍了ace 编辑器光标行为不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用 Ace 编辑器.

I am using Ace editor in my project.

CSS:

#editor {
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background-color:white;
}

JavaScript:

JavaScript:

var editor = ace.edit("editor");
editor.setTheme("ace/theme/textmate");
editor.getSession().setMode("ace/mode/java");

#editor 包含在一个相对定位的 div 中.

#editor is contained in a relatively positioned div.

这个问题很难解释,但我会努力的.

The problem is hard to explain but I'll try.

每当我在 Ace 中输入文本时,随着行大小的增加,光标实际位置的空间和预期位置都会增加.

Whenever I type text in Ace as the line size increases the spaces in the cursor's actual position and it's expected position increases.

例如,当我输入This is text"时,它显示如下:

For example when I type "This is text" it shows like this:

This is text           |

现在,当我按下退格键时,它会删除t"行的最后一个字符,并显示:

Now when I press backspace key it will delete last character on line 't', and will show:

This is tex           |

我在谷歌上搜索过这个问题,发现当缩放设置为 120 时,chrome 浏览器有一个类似的问题.但我正在使用 Firefox 浏览器.

I have searched about this issue on Google found one similar issue for chrome browser when zoom is set to 120. but I'm working on Firefox browser.

推荐答案

Ace 只能显示等宽字体,如果某些东西将编辑器的字体更改为非等宽字体,或者将不同的字体分配给不同部分的字体,则可能会发生您描述的问题编辑器.

Ace can display only monospace fonts, The issue you describe can happen either if something changes font of the editor to non monospace, or assigns different fonts to different parts of the editor.

(ubuntu 上有一个 firefox 插件,它将所有字体更改为非等宽字体)

(There was a firefox addon on ubuntu wich was changing all fonts to non monospace)

这篇关于ace 编辑器光标行为不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆