You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
Electron: Fixes #355: Set undo state properly when loading new note
This commit is contained in:
@@ -210,10 +210,13 @@ class NoteTextComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.editor_) {
|
if (this.editor_) {
|
||||||
const session = this.editor_.editor.getSession();
|
// Calling setValue here does two things:
|
||||||
const undoManager = session.getUndoManager();
|
// 1. It sets the initial value as recorded by the undo manager. If we were to set it instead to "" and wait for the render
|
||||||
undoManager.reset();
|
// phase to set the value, the initial value would still be "", which means pressing "undo" on a note that has just loaded
|
||||||
session.setUndoManager(undoManager);
|
// would clear it.
|
||||||
|
// 2. It resets the undo manager - fixes https://github.com/laurent22/joplin/issues/355
|
||||||
|
// Note: calling undoManager.reset() doesn't work
|
||||||
|
this.editor_.editor.session.setValue(note ? note.body : '');
|
||||||
this.editor_.editor.clearSelection();
|
this.editor_.editor.clearSelection();
|
||||||
this.editor_.editor.moveCursorTo(0,0);
|
this.editor_.editor.moveCursorTo(0,0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user