Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/NotepadNext/ScintillaNext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/NotepadNext/ScintillaNext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -139,6 +140,7 @@ public slots:
void renamed();

void lexerChanged();
void reloaded();

protected:
void dragEnterEvent(QDragEnterEvent *event) override;
Expand Down
1 change: 1 addition & 0 deletions src/NotepadNext/decorators/URLFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 9 additions & 1 deletion src/NotepadNext/dialogs/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<b>%1</b> 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");
Expand Down