From f696d1e6cf01209fa3cd0cbdff989c654352c904 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 16 Oct 2022 04:59:51 +0300 Subject: DiffEditor/VCS: Save document before applying/reverting patch chunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTCREATORBUG-22506 Change-Id: I646f24068c0c81890f36052537320a743fdeb498 Reviewed-by: André Hartmann Reviewed-by: hjk --- src/plugins/vcsbase/vcsbaseeditor.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins/vcsbase/vcsbaseeditor.cpp') diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index a73b2f4414..4b451ef2f9 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -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( + 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) -- cgit v1.2.1