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

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: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 3b68a46b
......@@ -1287,7 +1287,16 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString &currentFile)
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)
......
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