focus caret at line

scroll-to-line-with-scroll.js
John McLear 2020-12-10 23:23:28 +00:00
parent 1a577d53bd
commit a2a7322226
2 changed files with 19 additions and 0 deletions

View File

@ -682,6 +682,7 @@ function Ace2Inner() {
editorInfo.ace_doReturnKey = doReturnKey;
editorInfo.ace_isBlockElement = isBlockElement;
editorInfo.ace_getLineListType = getLineListType;
editorInfo.ace_setSelection = setSelection;
editorInfo.ace_callWithAce = function (fn, callStack, normalize) {
let wrapper = function () {

View File

@ -60,6 +60,24 @@ const padeditor = (function () {
.find('#outerdocbody').parent();
$outerdoc.css({top: `${offsetTop}px`}); // Chrome
$outerdocHTML.animate({scrollTop: offsetTop}); // needed for FF
const node = line[0];
self.ace.callWithAce((ace) => {
const selection = {
startPoint: {
index: 0,
focusAtStart: true,
maxIndex: 1,
node,
},
endPoint: {
index: 0,
focusAtStart: true,
maxIndex: 1,
node,
},
};
ace.ace_setSelection(selection);
});
}
}
}