Skip to content

Commit

Permalink
Merge pull request #106 from xwying/master
Browse files Browse the repository at this point in the history
fixed bugs in updating existing note when endSave is set
  • Loading branch information
stefanopagliari authored Jun 25, 2022
2 parents 243a922 + 6a78c30 commit 232ce98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ export default class MyPlugin extends Plugin {
//identify the keyword identifying the end of the section to be preserved. If is empty, the position is the end of the string. Otherwise find the match in the text
let endSaveOld: number = existingNote.length;
if (endSave !== "") {
endSaveOld = existingNote.indexOf(endSave) - 1;
endSaveOld = existingNote.indexOf(endSave) + endSave.length;
}
if (endSaveOld < 0) {
endSaveOld = existingNote.length;
Expand All @@ -2101,20 +2101,20 @@ export default class MyPlugin extends Plugin {
}

//identify the keyword identifying the ebd of the section to be preserved is empty, the position is the end of the string. Otherwise find the match in the text
let endSaveNew: number = newNote.length - 1;
let endSaveNew: number = newNote.length;
if (endSave !== "") {
endSaveNew = newNote.indexOf(endSave) - 1;
endSaveNew = newNote.indexOf(endSave) + endSave.length;
}
if (endSaveNew < 0) {
endSaveNew = newNote.length - 1;
endSaveNew = newNote.length;
}

//Find the sections of the existing note before the one to be preserved
const newNotePreservedBefore = newNote.substring(0, startSaveNew);
//Find the sections of the existing note after the one to be preserved
const newNotePreservedAfter = newNote.substring(
endSaveNew,
newNote.length - 1
newNote.length
);

const newNoteCombined =
Expand Down

0 comments on commit 232ce98

Please sign in to comment.