diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2022-10-16 04:59:51 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2022-10-19 09:31:48 +0000 |
commit | f696d1e6cf01209fa3cd0cbdff989c654352c904 (patch) | |
tree | d671095e4a7129534d71bcad67cb08d287534c6e /src/plugins/vcsbase/vcsbaseeditor.cpp | |
parent | 7edf7435836d044e05cdf0493861c07f4e91d367 (diff) | |
download | qt-creator-f696d1e6cf01209fa3cd0cbdff989c654352c904.tar.gz |
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>
Diffstat (limited to 'src/plugins/vcsbase/vcsbaseeditor.cpp')
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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<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) |