forked from qt-creator/qt-creator
Cut off the forward navigation history to avoid messing it up.
There are cases like when editing, or when jumping to a line, where we shouldn't cut it though (so we don't). Task-number: QTCREATORBUG-1535
This commit is contained in:
@@ -1066,7 +1066,6 @@ template <class EditorFactoryLike>
|
||||
IEditor *EditorManager::createEditor(const QString &editorId,
|
||||
const QString &fileName)
|
||||
{
|
||||
typedef QList<IEditorFactory*> FactoryList;
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << editorId << fileName;
|
||||
|
||||
@@ -1595,6 +1594,12 @@ void EditorManager::addCurrentPositionToNavigationHistory(IEditor *editor, const
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void EditorManager::cutForwardNavigationHistory()
|
||||
{
|
||||
currentEditorView()->cutForwardNavigationHistory();
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void EditorManager::goBackInNavigationHistory()
|
||||
{
|
||||
currentEditorView()->goBackInNavigationHistory();
|
||||
|
||||
@@ -145,6 +145,7 @@ public:
|
||||
QList<IEditor*> editorsForFiles(QList<IFile*> files) const;
|
||||
//QList<EditorGroup *> editorGroups() const;
|
||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
bool saveEditor(IEditor *editor);
|
||||
|
||||
|
||||
@@ -379,15 +379,21 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
|
||||
while (m_navigationHistory.size() >= 30) {
|
||||
if (m_currentNavigationHistoryPosition > 15) {
|
||||
m_navigationHistory.takeFirst();
|
||||
m_navigationHistory.removeFirst();
|
||||
--m_currentNavigationHistoryPosition;
|
||||
} else {
|
||||
m_navigationHistory.takeLast();
|
||||
m_navigationHistory.removeLast();
|
||||
}
|
||||
}
|
||||
updateNavigatorActions();
|
||||
}
|
||||
|
||||
void EditorView::cutForwardNavigationHistory()
|
||||
{
|
||||
while (m_currentNavigationHistoryPosition < m_navigationHistory.size() - 1)
|
||||
m_navigationHistory.removeLast();
|
||||
}
|
||||
|
||||
void EditorView::updateNavigatorActions()
|
||||
{
|
||||
m_toolBar->setCanGoBack(canGoBack());
|
||||
|
||||
@@ -135,6 +135,8 @@ public slots:
|
||||
|
||||
public:
|
||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
inline QList<EditLocation> editorHistory() const { return m_editorHistory; }
|
||||
|
||||
void copyNavigationHistoryFrom(EditorView* other);
|
||||
|
||||
@@ -1791,6 +1791,7 @@ bool CPPEditor::openCppEditorAt(const Link &link)
|
||||
|
||||
if (baseTextDocument()->fileName() == link.fileName) {
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
editorManager->cutForwardNavigationHistory();
|
||||
editorManager->addCurrentPositionToNavigationHistory();
|
||||
gotoLine(link.line, link.column);
|
||||
setFocus();
|
||||
|
||||
@@ -145,6 +145,7 @@ ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
||||
bool *newEditor)
|
||||
{
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
editorManager->cutForwardNavigationHistory();
|
||||
editorManager->addCurrentPositionToNavigationHistory();
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind,
|
||||
Core::EditorManager::IgnoreNavigationHistory, newEditor);
|
||||
|
||||
Reference in New Issue
Block a user