王牌编辑 - 走线

时间:2014-05-19 23:28:54

标签: javascript ace-editor

我尝试使用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

有什么建议吗?

感谢。

1 个答案:

答案 0 :(得分:11)

当前版本的Ace Editor似乎存在错误。如果您手动调用editor.resize(true),它将重新计算高度并且滚动功能正常工作:

var editor = ace.edit('editor');
editor.resize(true);

editor.scrollToLine(50, true, true, function () {});

editor.gotoLine(50, 10, true);

http://jsfiddle.net/Xu9Tb/1/

相关问题