forked from qt-creator/qt-creator
Editor: centrally emit filesChangedInternally after refactorings
...instead of relying on the surrounding code of the refactoring to emit the signal. This also ensures that the signal is only emitted for files that are not opened inside a TextEditor. Change-Id: I6223362864014c691962d895b864f9f44c36e035 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -252,10 +252,8 @@ void ClangdFindReferences::Private::handleRenameRequest(
|
||||
{
|
||||
const Utils::FilePaths filePaths = BaseFileFind::replaceAll(newSymbolName, checkedItems,
|
||||
preserveCase);
|
||||
if (!filePaths.isEmpty()) {
|
||||
DocumentManager::notifyFilesChangedInternally(filePaths);
|
||||
if (!filePaths.isEmpty())
|
||||
SearchResultWindow::instance()->hide();
|
||||
}
|
||||
|
||||
const auto renameFilesCheckBox = qobject_cast<QCheckBox *>(search->additionalReplaceWidget());
|
||||
QTC_ASSERT(renameFilesCheckBox, return);
|
||||
|
@@ -691,13 +691,10 @@ void SymbolSupport::handleRenameResponse(Core::SearchResult *search,
|
||||
void SymbolSupport::applyRename(const Utils::SearchResultItems &checkedItems,
|
||||
Core::SearchResult *search)
|
||||
{
|
||||
QSet<Utils::FilePath> affectedNonOpenFilePaths;
|
||||
QMap<Utils::FilePath, QList<TextEdit>> editsForDocuments;
|
||||
QList<DocumentChange> changes;
|
||||
for (const Utils::SearchResultItem &item : checkedItems) {
|
||||
const auto filePath = Utils::FilePath::fromUserInput(item.path().value(0));
|
||||
if (!m_client->documentForFilePath(filePath))
|
||||
affectedNonOpenFilePaths << filePath;
|
||||
const QJsonObject jsonObject = item.userData().toJsonObject();
|
||||
if (const TextEdit edit(jsonObject); edit.isValid())
|
||||
editsForDocuments[filePath] << edit;
|
||||
@@ -715,10 +712,6 @@ void SymbolSupport::applyRename(const Utils::SearchResultItems &checkedItems,
|
||||
for (auto it = editsForDocuments.begin(), end = editsForDocuments.end(); it != end; ++it)
|
||||
applyTextEdits(m_client, it.key(), it.value());
|
||||
|
||||
if (!affectedNonOpenFilePaths.isEmpty()) {
|
||||
Core::DocumentManager::notifyFilesChangedInternally(Utils::toList(affectedNonOpenFilePaths));
|
||||
}
|
||||
|
||||
const auto extraWidget = qobject_cast<ReplaceWidget *>(search->additionalReplaceWidget());
|
||||
QTC_ASSERT(extraWidget, return);
|
||||
if (!extraWidget->shouldRenameFiles())
|
||||
|
@@ -388,7 +388,6 @@ void BaseFileFind::doReplace(const QString &text, const SearchResultItems &items
|
||||
if (!files.isEmpty()) {
|
||||
FadingIndicator::showText(ICore::dialogParent(),
|
||||
Tr::tr("%n occurrences replaced.", nullptr, items.size()), FadingIndicator::SmallText);
|
||||
DocumentManager::notifyFilesChangedInternally(files);
|
||||
SearchResultWindow::instance()->hide();
|
||||
}
|
||||
}
|
||||
|
@@ -355,9 +355,9 @@ bool RefactoringFile::apply()
|
||||
QString error;
|
||||
// suppress "file has changed" warnings if the file is open in a read-only editor
|
||||
Core::FileChangeBlocker block(m_filePath);
|
||||
if (!m_textFileFormat.writeFile(m_filePath,
|
||||
doc->toPlainText(),
|
||||
&error)) {
|
||||
if (m_textFileFormat.writeFile(m_filePath, doc->toPlainText(), &error)) {
|
||||
Core::DocumentManager::notifyFilesChangedInternally({m_filePath});
|
||||
} else {
|
||||
qWarning() << "Could not apply changes to" << m_filePath
|
||||
<< ". Error: " << error;
|
||||
result = false;
|
||||
|
Reference in New Issue
Block a user