aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/refactoringchanges.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2021-08-17 17:59:51 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2021-08-19 08:58:44 +0000
commit35fcd96b8500472e80f11cd40182639ae1a18648 (patch)
tree9d67b15c2d346c6d0d662d0903a2fa8e558dfecf /src/plugins/texteditor/refactoringchanges.cpp
parent3d920bc00032174d72d9a131eb001f52400f1256 (diff)
TextEditor: Optionally auto-save refactored files
This is particularly helpful with clangd, which considers only the on- disk state of header files when parsing dependent sources. Fixes: QTCREATORBUG-25924 Change-Id: I41d313f8a203a576d3ed5fbe75bbe918334486d4 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.cpp')
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index d307b8cda7..6872c18c60 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -342,6 +342,7 @@ bool RefactoringFile::apply()
m_editorCursorPosition = -1;
}
+ const bool withUnmodifiedEditor = m_editor && !m_editor->textDocument()->isModified();
bool result = true;
// apply changes, if any
@@ -390,6 +391,8 @@ bool RefactoringFile::apply()
}
fileChanged();
+ if (withUnmodifiedEditor && EditorManager::autoSaveAfterRefactoring())
+ m_editor->textDocument()->save(nullptr, m_filePath, false);
}
}