fix and simplify applyScrollInfo
This commit is contained in:
parent
c423025c5d
commit
ad43560016
12
edit/edit.js
12
edit/edit.js
|
@ -4,7 +4,7 @@
|
|||
/* global SectionsEditor */
|
||||
/* global SourceEditor */
|
||||
/* global clipString createHotkeyInput helpPopup */// util.js
|
||||
/* global closeCurrentTab deepEqual sessionStore tryJSONparse */// toolbox.js
|
||||
/* global closeCurrentTab deepEqual mapObj sessionStore tryJSONparse */// toolbox.js
|
||||
/* global cmFactory */
|
||||
/* global editor EditorHeader */// base.js
|
||||
/* global linterMan */
|
||||
|
@ -207,11 +207,10 @@ function EditorMethods() {
|
|||
applyScrollInfo(cm, si = (editor.scrollInfo.cms || [])[0]) {
|
||||
if (si && si.sel) {
|
||||
const bmOpts = {sublimeBookmark: true, clearWhenEmpty: false}; // copied from sublime.js
|
||||
cm.operation(() => {
|
||||
cm.setSelections(...si.sel, {scroll: false});
|
||||
cm.scrollIntoView(cm.getCursor(), si.parentHeight / 2);
|
||||
cm.state.sublimeBookmarks = si.bookmarks.map(b => cm.markText(b.from, b.to, bmOpts));
|
||||
});
|
||||
cm.setSelections(...si.sel, {scroll: false});
|
||||
cm.state.sublimeBookmarks = si.bookmarks.map(b => cm.markText(b.from, b.to, bmOpts));
|
||||
Object.assign(cm.display.scroller, si.scroll); // for source editor
|
||||
Object.assign(cm.doc, si.scroll); // for sectioned editor
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -223,6 +222,7 @@ function EditorMethods() {
|
|||
focus: cm.hasFocus(),
|
||||
height: cm.display.wrapper.style.height.replace('100vh', ''),
|
||||
parentHeight: cm.display.wrapper.parentElement.offsetHeight,
|
||||
scroll: mapObj(cm.doc, null, ['scrollLeft', 'scrollTop']),
|
||||
sel: [cm.doc.sel.ranges, cm.doc.sel.primIndex],
|
||||
})),
|
||||
};
|
||||
|
|
|
@ -101,7 +101,6 @@ async function SourceEditor() {
|
|||
'editor.toc.expanded': (k, val) => sectionFinder.onOff(editor.updateToc, val),
|
||||
}, {runNow: true});
|
||||
|
||||
editor.applyScrollInfo(cm);
|
||||
cm.clearHistory();
|
||||
cm.markClean();
|
||||
savedGeneration = cm.changeGeneration();
|
||||
|
@ -121,6 +120,7 @@ async function SourceEditor() {
|
|||
if (!$isTextInput(document.activeElement)) {
|
||||
cm.focus();
|
||||
}
|
||||
editor.applyScrollInfo(cm); // WARNING! Place it after all cm.XXX calls that change scroll pos
|
||||
|
||||
async function preprocess(style) {
|
||||
const res = await API.usercss.build({
|
||||
|
|
Loading…
Reference in New Issue
Block a user