- enhancement: Pause autosave timer when autosave new files.

This commit is contained in:
Roy Qu 2023-01-26 11:33:27 +08:00
parent 7b13d3a519
commit 79bf453c6c
1 changed files with 30 additions and 31 deletions

View File

@ -2431,11 +2431,6 @@ void MainWindow::doAutoSave(Editor *e)
QString suffix = fileInfo.suffix();
switch(pSettings->editor().autoSaveStrategy()) {
case assOverwrite:
if (e->isNew()) {
mAutoSaveTimer.stop();
e->save();
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
} else
e->save();
return;
case assAppendUnixTimestamp:
@ -2455,9 +2450,7 @@ void MainWindow::doAutoSave(Editor *e)
}
}
if (e->isNew()) {
mAutoSaveTimer.stop();
e->saveAs();
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
} else {
e->saveFile(filename);
e->setCanAutoSave(false);
@ -3449,6 +3442,11 @@ void MainWindow::onAutoSaveTimeout()
return;
if (!pSettings->editor().enableAutoSave())
return;
mAutoSaveTimer.stop();
{
auto action=finally([this]{
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
});
int updateCount = 0;
switch (pSettings->editor().autoSaveTarget()) {
case astCurrentFile: {
@ -3479,6 +3477,7 @@ void MainWindow::onAutoSaveTimeout()
}
updateStatusbarMessage(tr("%1 files autosaved").arg(updateCount));
}
}
void MainWindow::onWatchViewContextMenu(const QPoint &pos)
{