diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index 68b92567f..9f091a480 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -347,11 +347,26 @@ void ScintillaNext::reload() if (readSuccessful) { updateTimestamp(); setSavePoint(); + + // If this was a temporary file, make sure it is not any more + setTemporary(false); + + emit reloaded(); } return; } +void ScintillaNext::omitModifications() +{ + // If file modifications will be omitted just update file timestamp + // so pop-up will be displayed only once per file modifications. + updateTimestamp(); + setTemporary(true); + + return; +} + QFileDevice::FileError ScintillaNext::saveAs(const QString &newFilePath) { bool isRenamed = bufferType == ScintillaNext::New || fileInfo.canonicalFilePath() != newFilePath; diff --git a/src/NotepadNext/ScintillaNext.h b/src/NotepadNext/ScintillaNext.h index 5d3d38bf8..70a1f07b4 100644 --- a/src/NotepadNext/ScintillaNext.h +++ b/src/NotepadNext/ScintillaNext.h @@ -122,6 +122,7 @@ public slots: void close(); QFileDevice::FileError save(); void reload(); + void omitModifications(); QFileDevice::FileError saveAs(const QString &newFilePath); QFileDevice::FileError saveCopyAs(const QString &filePath); bool rename(const QString &newFilePath); @@ -139,6 +140,7 @@ public slots: void renamed(); void lexerChanged(); + void reloaded(); protected: void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/src/NotepadNext/decorators/URLFinder.cpp b/src/NotepadNext/decorators/URLFinder.cpp index 66a124d53..f0b2242bc 100644 --- a/src/NotepadNext/decorators/URLFinder.cpp +++ b/src/NotepadNext/decorators/URLFinder.cpp @@ -46,6 +46,7 @@ URLFinder::URLFinder(ScintillaNext *editor) : connect(this, &EditorDecorator::stateChanged, this, [=](bool b) { if (b) { connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); + connect(editor, &ScintillaNext::reloaded, timer, qOverload<>(&QTimer::start)); findURLs(); } else { diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 30df2415c..84be9ebbb 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1854,7 +1854,15 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) } else if (state == ScintillaNext::Modified) { qInfo("ScintillaNext::Modified"); - editor->reload(); + const QString filePath = editor->getFilePath(); + auto reply = QMessageBox::question(this, tr("Reload File"), tr("%1 has been modified by another program. Do you want to reload it?").arg(filePath)); + + if (reply == QMessageBox::Yes) { + editor->reload(); + } + else { + editor->omitModifications(); + } } else if (state == ScintillaNext::Deleted) { qInfo("ScintillaNext::Deleted");