Skip to content

Commit

Permalink
fix: #978 尝试修复editor.keepDocumentScrollAfterInit=true失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Nov 17, 2024
1 parent 2e54a7e commit fded636
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Cherry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fded636

Please sign in to comment.