Skip to content

Commit aeee5fc

Browse files
committed
#3366 note: fix reloading of recently edited current note, that was changed externally
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 3cdb4b4 commit aeee5fc

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# QOwnNotes Changelog
22

3+
## 25.12.4
4+
5+
- Fixed an issue where external changes to recently edited notes were silently
6+
ignored instead of showing the diff dialog (for [#3366](https://github.com/pbek/QOwnNotes/issues/3366))
7+
- When a note was edited within the last 60 seconds and then changed externally,
8+
small changes (≤8 characters difference) would be ignored without notification
9+
- The similarity check is now skipped for recently edited notes to ensure the
10+
diff dialog is always shown, preventing potential data loss
11+
- Notes that haven't been edited for a while continue to auto-reload silently
12+
for small external changes as intended
13+
314
## 25.12.3
415

516
- Fixed an issue where the diff dialog was incorrectly triggered when both

src/mainwindow.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,9 @@ void MainWindow::notesWereModified(const QString &str) {
28662866
const bool isCurrentNoteNotEditedForAWhile =
28672867
this->currentNoteLastEdited.addSecs(60) < QDateTime::currentDateTime();
28682868
// If the current note wasn't edited for a while, we want that it is possible
2869-
// to get updated even with small changes, so we are setting a threshold of 0
2869+
// to get updated even with small changes, so we are setting a threshold of 0.
2870+
// If it was recently edited, we use a threshold of 8 for the similarity check
2871+
// to avoid false positives, but we'll still show the dialog if changes are detected.
28702872
const int threshold = isCurrentNoteNotEditedForAWhile ? 0 : 8;
28712873

28722874
// Check if the old note text is the same or similar as the one on disk
@@ -2891,8 +2893,10 @@ void MainWindow::notesWereModified(const QString &str) {
28912893
const QString noteTextEditText = this->ui->noteTextEdit->toPlainText();
28922894

28932895
// skip dialog if text of note file on disk text from note text
2894-
// edit are equal or similar
2895-
if (Utils::Misc::isSimilar(noteTextEditText, noteTextOnDisk, threshold)) {
2896+
// edit are equal or similar, but only if the note wasn't edited recently
2897+
// If it was recently edited, we want to show the dialog even for small changes
2898+
if (isCurrentNoteNotEditedForAWhile &&
2899+
Utils::Misc::isSimilar(noteTextEditText, noteTextOnDisk, threshold)) {
28962900
qDebug() << __func__ << " - Note text and text on disk are too similar, ignoring";
28972901
return;
28982902
}

0 commit comments

Comments
 (0)