CppEditor: Only open refactored file in editor if we have a position

It's just confusing to the user otherwise.

Fixes: QTCREATORBUG-27114
Change-Id: I127d97ca165af0eb751cd6479d0ec0ffec480c17
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-02-25 14:11:47 +01:00
parent 5d770bc8c4
commit d60c8787cd

View File

@@ -3476,18 +3476,24 @@ public:
};
for (auto spec : classLayout) {
const auto iter = m_headerFileCode.find(spec);
if (iter != m_headerFileCode.end())
insertAndIndent(m_headerFile, headerLocationFor(spec), *iter);
if (iter != m_headerFileCode.end()) {
const InsertionLocation loc = headerLocationFor(spec);
m_headerFile->setOpenEditor(true, m_headerFile->position(loc.line(), loc.column()));
insertAndIndent(m_headerFile, loc, *iter);
}
}
if (!m_sourceFileCode.isEmpty() && m_sourceFileInsertionPoint.isValid())
if (!m_sourceFileCode.isEmpty() && m_sourceFileInsertionPoint.isValid()) {
m_sourceFile->setOpenEditor(true, m_sourceFile->position(
m_sourceFileInsertionPoint.line(),
m_sourceFileInsertionPoint.column()));
insertAndIndent(m_sourceFile, m_sourceFileInsertionPoint, m_sourceFileCode);
}
if (!m_headerFileChangeSet.isEmpty()) {
m_headerFile->setChangeSet(m_headerFileChangeSet);
m_headerFile->apply();
}
if (!m_sourceFileChangeSet.isEmpty()) {
m_sourceFile->setOpenEditor();
m_sourceFile->setChangeSet(m_sourceFileChangeSet);
m_sourceFile->apply();
}