You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
Electron: Fixes #479: Currently loaded note was cleared when creating new note
This commit is contained in:
@@ -215,8 +215,17 @@ class NoteTextComponent extends React.Component {
|
|||||||
// phase to set the value, the initial value would still be "", which means pressing "undo" on a note that has just loaded
|
// phase to set the value, the initial value would still be "", which means pressing "undo" on a note that has just loaded
|
||||||
// would clear it.
|
// would clear it.
|
||||||
// 2. It resets the undo manager - fixes https://github.com/laurent22/joplin/issues/355
|
// 2. It resets the undo manager - fixes https://github.com/laurent22/joplin/issues/355
|
||||||
// Note: calling undoManager.reset() doesn't work
|
// Note: calling undoManager.reset() doesn't work
|
||||||
this.editor_.editor.session.setValue(note ? note.body : '');
|
try {
|
||||||
|
this.editor_.editor.getSession().setValue(note ? note.body : '');
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message === "Cannot read property 'match' of undefined") {
|
||||||
|
// The internals of Ace Editor throws an exception when creating a new note,
|
||||||
|
// but that can be ignored.
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
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