forked from qt-creator/qt-creator
Vcs: Find better line-number to scroll annotate output to
Use new TextEditorWidget::firstVisibleLine, etc. methods to find a better line to center on. Task-number: QTCREATORBUG-14230 Change-Id: I36424fcd1200d362d06c456e7b4c13e671dbd4b6 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -1287,7 +1287,16 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile)
|
||||
const BaseTextEditor *eda = qobject_cast<const BaseTextEditor *>(ed);
|
||||
if (!eda)
|
||||
return -1;
|
||||
return eda->currentLine();
|
||||
const int cursorLine = eda->currentLine();
|
||||
auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget());
|
||||
if (edw) {
|
||||
const int firstLine = edw->firstVisibleLine();
|
||||
const int lastLine = edw->lastVisibleLine();
|
||||
if (firstLine <= cursorLine && cursorLine < lastLine)
|
||||
return cursorLine;
|
||||
return edw->centerVisibleLine();
|
||||
}
|
||||
return cursorLine;
|
||||
}
|
||||
|
||||
bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber)
|
||||
|
||||
Reference in New Issue
Block a user