Editor: Fix block for offset calculation

Take block bounding rects into account, when calculating the row count
or the center visible line.

Change-Id: If933828867df25920eeb56359e9a42a8b95d9c6d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2017-11-23 14:17:48 +01:00
parent c67902ec4e
commit 464a9ad9ab
3 changed files with 50 additions and 19 deletions

View File

@@ -1303,14 +1303,14 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString &currentFile)
const BaseTextEditor *eda = qobject_cast<const BaseTextEditor *>(ed);
if (!eda)
return -1;
const int cursorLine = eda->currentLine();
const int cursorLine = eda->textCursor().blockNumber();
auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget());
if (edw) {
const int firstLine = edw->firstVisibleLine();
const int lastLine = edw->lastVisibleLine();
const int firstLine = edw->firstVisibleBlockNumber();
const int lastLine = edw->lastVisibleBlockNumber();
if (firstLine <= cursorLine && cursorLine < lastLine)
return cursorLine;
return edw->centerVisibleLine();
return edw->centerVisibleBlockNumber();
}
return cursorLine;
}