diff --git a/src/plugins/projectexplorer/doubletabwidget.cpp b/src/plugins/projectexplorer/doubletabwidget.cpp
index 33f9157e0c5d93f423db4061d15e2ac6030a3ad1..95010781afc17cc2f3c253af73fe7baef18f5652 100644
--- a/src/plugins/projectexplorer/doubletabwidget.cpp
+++ b/src/plugins/projectexplorer/doubletabwidget.cpp
@@ -119,7 +119,7 @@ void DoubleTabWidget::insertTab(int index, const QString &name, const QStringLis
     tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0;
     m_tabs.insert(index, tab);
     if (m_currentIndex == -1) {
-        m_currentIndex = m_tabs.size()-1;
+        m_currentIndex = index;
         emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
     } else if (m_currentIndex >= index) {
         ++m_currentIndex;