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

Любой совет?

Спасибо.


person M Miller    schedule 19.05.2014    source источник


Ответы (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/

person M Miller    schedule 19.05.2014
comment
это тоже, к сожалению, кажется сломанным в последней версии (v1.2.6) - person tkit; 24.01.2017