我正在使用 Ace Editor 尝试一个相当简单的操作:让编辑器跳转到特定行。不过,我无法让它工作!
请参阅此 jsFiddle:http://jsfiddle.net/Xu9Tb/
var editor = ace.edit('editor');
editor.scrollToLine(50, true, true, function () {});
// Doesn't do anything at all
editor.gotoLine(50, 10, true);
// Will move the caret to the line, but it will not scroll
// to the editor to the line if it's off screen
有什么建议吗?
谢谢。
最佳答案
当前版本的 Ace Editor 中似乎存在错误。如果您手动调用 editor.resize(true)
,它将重新计算高度并且滚动功能可以正常工作:
var editor = ace.edit('editor');
editor.resize(true);
editor.scrollToLine(50, true, true, function () {});
editor.gotoLine(50, 10, true);
关于javascript - Ace 编辑器 - 转到行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23748743/