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>
This commit is contained in:
Christian Kandeler
2021-08-17 17:59:51 +02:00
parent 3d920bc000
commit 35fcd96b85
6 changed files with 283 additions and 241 deletions

View File

@@ -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);
}
}