Commit 5c60bb9d authored by Tobias Hunger's avatar Tobias Hunger

DiffEditor: When jumping to a file then put that block to the top

When jumping to a file via the dropdown box: Have that block be
scrolled to the top of the view, not to the center. This is way
less confusing.

Change-Id: I5c629dda1af8bff76ca93a70357aa35c8efcb37a
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 804a5731
......@@ -631,14 +631,14 @@ void SideBySideDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex)
QTextCursor leftCursor = m_leftEditor->textCursor();
leftCursor.setPosition(leftBlock.position());
m_leftEditor->setTextCursor(leftCursor);
m_leftEditor->verticalScrollBar()->setValue(blockNumber);
QTextBlock rightBlock = m_rightEditor->document()->findBlockByNumber(blockNumber);
QTextCursor rightCursor = m_rightEditor->textCursor();
rightCursor.setPosition(rightBlock.position());
m_rightEditor->setTextCursor(rightCursor);
m_rightEditor->verticalScrollBar()->setValue(blockNumber);
m_leftEditor->centerCursor();
m_rightEditor->centerCursor();
m_ignoreCurrentIndexChange = oldIgnore;
}
......
......@@ -37,6 +37,7 @@
#include <QPlainTextEdit>
#include <QMenu>
#include <QPlainTextDocumentLayout>
#include <QScrollBar>
#include <QTextBlock>
#include <QTextCodec>
#include <QPainter>
......@@ -734,7 +735,7 @@ void UnifiedDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex)
QTextCursor cursor = textCursor();
cursor.setPosition(block.position());
setTextCursor(cursor);
centerCursor();
verticalScrollBar()->setValue(blockNumber);
m_ignoreCurrentIndexChange = oldIgnore;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment