diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index e59c376efef3b25887df3f400cf71b5b171be84b..42d3e59a23e70a762f4ad055c7f2716e67c0254d 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1314,8 +1314,8 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
         } else {
             title = *titlePattern;
         }
+        *titlePattern = title;
     }
-    *titlePattern = title;
     edt->setDisplayName(title);
     addEditor(edt);
     QApplication::restoreOverrideCursor();