diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 65497dbe72a..f7164dc0d51 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -2221,12 +2221,8 @@ EditorManager::ExternalEditorList IEditor *EditorManager::openEditor(const QString &fileName, Id editorId, OpenEditorFlags flags, bool *newEditor) { - if (flags & EditorManager::OpenInOtherSplit) { - if (flags & EditorManager::NoNewSplits) - EditorManagerPrivate::gotoNextSplit(); - else - EditorManager::gotoOtherSplit(); - } + if (flags & EditorManager::OpenInOtherSplit) + EditorManager::gotoOtherSplit(); return EditorManagerPrivate::openEditor(EditorManagerPrivate::currentEditorView(), fileName, editorId, flags, newEditor); @@ -2235,6 +2231,9 @@ IEditor *EditorManager::openEditor(const QString &fileName, Id editorId, IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column, Id editorId, OpenEditorFlags flags, bool *newEditor) { + if (flags & EditorManager::OpenInOtherSplit) + EditorManager::gotoOtherSplit(); + return EditorManagerPrivate::openEditorAt(EditorManagerPrivate::currentEditorView(), fileName, line, column, editorId, flags, newEditor); } @@ -2297,12 +2296,8 @@ IEditor *EditorManager::openEditorWithContents(Id editorId, if (debugEditorManager) qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << contents; - if (flags & EditorManager::OpenInOtherSplit) { - if (flags & EditorManager::NoNewSplits) - EditorManagerPrivate::gotoNextSplit(); - else + if (flags & EditorManager::OpenInOtherSplit) EditorManager::gotoOtherSplit(); - } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index ecbf848a48a..d9273b040d2 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -105,8 +105,7 @@ public: IgnoreNavigationHistory = 2, DoNotMakeVisible = 4, CanContainLineNumber = 8, - OpenInOtherSplit = 16, - NoNewSplits = 32 + OpenInOtherSplit = 16 }; Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 443e3916413..1cd293259b5 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -417,7 +417,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit) // Open Editor at link position if (symbolLink.hasValidTarget()) - openCppEditorAt(symbolLink, inNextSplit != alwaysOpenLinksInNextSplit()); + openLink(symbolLink, inNextSplit != alwaysOpenLinksInNextSplit()); } CppEditorWidget::Link CppEditorWidget::findLinkAt(const QTextCursor &cursor, bool resolveTarget, @@ -576,21 +576,6 @@ CppEditorWidget::Link CppEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol) return Link(filename, line, column); } -bool CppEditorWidget::openCppEditorAt(const Link &link, bool inNextSplit) -{ - if (!link.hasValidTarget()) - return false; - - EditorManager::OpenEditorFlags flags; - if (inNextSplit) - flags |= EditorManager::OpenInOtherSplit; - return EditorManager::openEditorAt(link.targetFileName, - link.targetLine, - link.targetColumn, - Constants::CPPEDITOR_ID, - flags); -} - void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo, bool updateUseSelectionSynchronously) { diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index b5950ab4a0c..e599312b02b 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -104,9 +104,6 @@ protected: void applyFontSettings() Q_DECL_OVERRIDE; - bool openLink(const Link &link, bool inNextSplit) Q_DECL_OVERRIDE - { return openCppEditorAt(link, inNextSplit); } - Link findLinkAt(const QTextCursor &, bool resolveTarget = true, bool inNextSplit = false) Q_DECL_OVERRIDE; @@ -140,8 +137,6 @@ private: void finalizeInitialization() Q_DECL_OVERRIDE; void finalizeInitializationAfterDuplication(BaseTextEditorWidget *other) Q_DECL_OVERRIDE; - static bool openCppEditorAt(const Link &, bool inNextSplit = false); - unsigned documentRevision() const; private: diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index d0a428858a2..f91c8ad8d26 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -5334,16 +5334,18 @@ bool BaseTextEditorWidget::openLink(const Link &link, bool inNextSplit) if (!link.hasValidTarget()) return false; - if (inNextSplit) { - EditorManager::gotoOtherSplit(); - } else if (textDocument()->filePath() == link.targetFileName) { + if (!inNextSplit && textDocument()->filePath() == link.targetFileName) { EditorManager::addCurrentPositionToNavigationHistory(); gotoLine(link.targetLine, link.targetColumn); setFocus(); return true; } + EditorManager::OpenEditorFlags flags; + if (inNextSplit) + flags |= EditorManager::OpenInOtherSplit; - return EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn); + return EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn, + Id(), flags); } void BaseTextEditorWidgetPrivate::updateLink(QMouseEvent *e) diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 662f1bd49b4..82172e828ba 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -580,10 +580,9 @@ protected: bool inNextSplit = false); /*! - Reimplement this function if you want to customize the way a link is - opened. Returns whether the link was opened successfully. + Returns whether the link was opened successfully. */ - virtual bool openLink(const Link &link, bool inNextSplit = false); + bool openLink(const Link &link, bool inNextSplit = false); /*! Reimplement this function to change the default replacement text.