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,
|
IEditor *EditorManager::createEditor(const QString &editorId,
|
||||||
const QString &fileName)
|
const QString &fileName)
|
||||||
{
|
{
|
||||||
typedef QList<IEditorFactory*> FactoryList;
|
|
||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
qDebug() << Q_FUNC_INFO << editorId << fileName;
|
qDebug() << Q_FUNC_INFO << editorId << fileName;
|
||||||
|
|
||||||
@@ -1595,6 +1594,12 @@ void EditorManager::addCurrentPositionToNavigationHistory(IEditor *editor, const
|
|||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorManager::cutForwardNavigationHistory()
|
||||||
|
{
|
||||||
|
currentEditorView()->cutForwardNavigationHistory();
|
||||||
|
updateActions();
|
||||||
|
}
|
||||||
|
|
||||||
void EditorManager::goBackInNavigationHistory()
|
void EditorManager::goBackInNavigationHistory()
|
||||||
{
|
{
|
||||||
currentEditorView()->goBackInNavigationHistory();
|
currentEditorView()->goBackInNavigationHistory();
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public:
|
|||||||
QList<IEditor*> editorsForFiles(QList<IFile*> files) const;
|
QList<IEditor*> editorsForFiles(QList<IFile*> files) const;
|
||||||
//QList<EditorGroup *> editorGroups() const;
|
//QList<EditorGroup *> editorGroups() const;
|
||||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||||
|
void cutForwardNavigationHistory();
|
||||||
|
|
||||||
bool saveEditor(IEditor *editor);
|
bool saveEditor(IEditor *editor);
|
||||||
|
|
||||||
|
|||||||
@@ -379,15 +379,21 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
|||||||
|
|
||||||
while (m_navigationHistory.size() >= 30) {
|
while (m_navigationHistory.size() >= 30) {
|
||||||
if (m_currentNavigationHistoryPosition > 15) {
|
if (m_currentNavigationHistoryPosition > 15) {
|
||||||
m_navigationHistory.takeFirst();
|
m_navigationHistory.removeFirst();
|
||||||
--m_currentNavigationHistoryPosition;
|
--m_currentNavigationHistoryPosition;
|
||||||
} else {
|
} else {
|
||||||
m_navigationHistory.takeLast();
|
m_navigationHistory.removeLast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateNavigatorActions();
|
updateNavigatorActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorView::cutForwardNavigationHistory()
|
||||||
|
{
|
||||||
|
while (m_currentNavigationHistoryPosition < m_navigationHistory.size() - 1)
|
||||||
|
m_navigationHistory.removeLast();
|
||||||
|
}
|
||||||
|
|
||||||
void EditorView::updateNavigatorActions()
|
void EditorView::updateNavigatorActions()
|
||||||
{
|
{
|
||||||
m_toolBar->setCanGoBack(canGoBack());
|
m_toolBar->setCanGoBack(canGoBack());
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ public slots:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||||
|
void cutForwardNavigationHistory();
|
||||||
|
|
||||||
inline QList<EditLocation> editorHistory() const { return m_editorHistory; }
|
inline QList<EditLocation> editorHistory() const { return m_editorHistory; }
|
||||||
|
|
||||||
void copyNavigationHistoryFrom(EditorView* other);
|
void copyNavigationHistoryFrom(EditorView* other);
|
||||||
|
|||||||
@@ -1791,6 +1791,7 @@ bool CPPEditor::openCppEditorAt(const Link &link)
|
|||||||
|
|
||||||
if (baseTextDocument()->fileName() == link.fileName) {
|
if (baseTextDocument()->fileName() == link.fileName) {
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
|
editorManager->cutForwardNavigationHistory();
|
||||||
editorManager->addCurrentPositionToNavigationHistory();
|
editorManager->addCurrentPositionToNavigationHistory();
|
||||||
gotoLine(link.line, link.column);
|
gotoLine(link.line, link.column);
|
||||||
setFocus();
|
setFocus();
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
|||||||
bool *newEditor)
|
bool *newEditor)
|
||||||
{
|
{
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
|
editorManager->cutForwardNavigationHistory();
|
||||||
editorManager->addCurrentPositionToNavigationHistory();
|
editorManager->addCurrentPositionToNavigationHistory();
|
||||||
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind,
|
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind,
|
||||||
Core::EditorManager::IgnoreNavigationHistory, newEditor);
|
Core::EditorManager::IgnoreNavigationHistory, newEditor);
|
||||||
|
|||||||
Reference in New Issue
Block a user