diff --git a/src/Cherry.js b/src/Cherry.js index 6a760760..2993ee1d 100644 --- a/src/Cherry.js +++ b/src/Cherry.js @@ -481,7 +481,6 @@ export default class Cherry extends CherryStatic { * @param {boolean} keepCursor 是否保持光标位置 */ setValue(content, keepCursor = false) { - this.editor.storeDocumentScroll(); if (keepCursor === false) { return this.editor.editor.setValue(content); } @@ -965,8 +964,9 @@ export default class Cherry extends CherryStatic { }); } // 强制每次编辑(包括undo、redo)编辑器都会自动滚动到光标位置 - codemirror.scrollIntoView(null); - this.editor.restoreDocumentScroll(); + if (!this.options.editor.keepDocumentScrollAfterInit) { + codemirror.scrollIntoView(null); + } }, interval); } catch (e) { throw new NestedError(e);