【问题标题】:Ace Editor - Go to line王牌编辑器 - 转到行
【发布时间】:2014-05-19 23:28:53
【问题描述】:

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

有什么建议吗?

谢谢。

【问题讨论】:

    标签: javascript ace-editor


    【解决方案1】:

    当前版本的 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/

    【讨论】:

    • 不幸的是,这似乎在最新版本(v1.2.6)中被破坏了
    猜你喜欢
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多