DiffEditor/VCS: Save document before applying/reverting patch chunk

Fixes: QTCREATORBUG-22506
Change-Id: I646f24068c0c81890f36052537320a743fdeb498
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2022-10-16 04:59:51 +03:00
committed by Orgad Shaneh
parent 7edf743583
commit f696d1e6cf
4 changed files with 23 additions and 9 deletions

View File

@@ -1578,7 +1578,14 @@ bool VcsBaseEditorWidget::hasDiff() const
void VcsBaseEditorWidget::slotApplyDiffChunk(const DiffChunk &chunk, PatchAction patchAction)
{
if (!PatchTool::confirmPatching(this, patchAction))
auto textDocument = qobject_cast<TextEditor::TextDocument *>(
DocumentModel::documentForFilePath(chunk.fileName));
const bool isModified = textDocument && textDocument->isModified();
if (!PatchTool::confirmPatching(this, patchAction, isModified))
return;
if (textDocument && !EditorManager::saveDocument(textDocument))
return;
if (applyDiffChunk(chunk, patchAction) && patchAction == PatchAction::Revert)