1
0
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:
Laurent Cozic
2018-05-01 21:13:17 +01:00
parent 784ba45f1f
commit 11d323d8b7

View File

@@ -216,7 +216,16 @@ class NoteTextComponent extends React.Component {
// 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 : '');
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.moveCursorTo(0,0);
}