问题:是否有一种方法可以在编辑器完全加载后执行Ace编辑器命令?
我试图在页面加载/重新加载之后设置Ace编辑器的光标位置。在加载编辑器时,将在其中一个回调中设置编辑器的内容。在这里设置光标位置不起作用,因为编辑器的其余部分仍在加载(如VirtualRenderer),它将编辑器内容重置为从顶部显示。
下面的代码工作,它设置内容,代码折叠,和光标的位置。然而,光标在屏幕上结束,从顶部显示内容。在编辑器完全加载之后,我希望它滚动到光标。
//Put the content of the file into the editor
editor.session.setValue(content);
//Restore code folds
for(var i = 0; i < folds.length; i++) {
editor.session.addFold("...",folds[i]);
}
//Put the cursor in the correct place
editor.gotoLine(cursor.row,cursor.column, true);
editor.renderer.scrollToRow(cursor.row);发布于 2017-09-30 15:20:22
你能试试这个吗?
//Put the content of the file into the editor
editor.session.setValue(content);
//Restore code folds
for(var i = 0; i < folds.length; i++) {
editor.session.addFold("...",folds[i]);
}
//Put the cursor in the correct place
editor.focus();
editor.gotoLine(cursor.row,cursor.column, true);
editor.renderer.scrollToRow(cursor.row);https://stackoverflow.com/questions/41371947
复制相似问题