1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Electron: #22 Fixes keyboard cursor jumps while typing.

This commit is contained in:
Laurent Cozic
2017-12-01 00:00:18 +00:00
parent 5e6a389f97
commit e1b1f31cf1
2 changed files with 19 additions and 5 deletions

View File

@@ -13,11 +13,11 @@ shared.noteExists = async function(noteId) {
shared.saveNoteButton_press = async function(comp) {
let note = Object.assign({}, comp.state.note);
// Note has been deleted while user was modifying it. In that, we
// Note has been deleted while user was modifying it. In that case, we
// just save a new note by clearing the note ID.
if (note.id && !(await shared.noteExists(note.id))) delete note.id;
reg.logger().info('Saving note: ', note);
// reg.logger().info('Saving note: ', note);
if (!note.parent_id) {
let folder = await Folder.defaultFolder();
@@ -46,9 +46,19 @@ shared.saveNoteButton_press = async function(comp) {
const savedNote = await Note.save(diff);
const stateNote = comp.state.note;
// Re-assign any property that might have changed during saving (updated_time, etc.)
note = Object.assign(note, savedNote);
if (stateNote) {
// But we preserve the current title and body because
// the user might have changed them between the time
// saveNoteButton_press was called and the note was
// saved (it's done asynchronously)
note.title = stateNote.title;
note.body = stateNote.body;
}
comp.setState({
lastSavedNote: Object.assign({}, note),
note: note,
@@ -65,7 +75,7 @@ shared.saveOneProperty = async function(comp, name, value) {
// just save a new note by clearing the note ID.
if (note.id && !(await shared.noteExists(note.id))) delete note.id;
reg.logger().info('Saving note property: ', note.id, name, value);
// reg.logger().info('Saving note property: ', note.id, name, value);
if (note.id) {
let toSave = { id: note.id };