forked from qt-creator/qt-creator
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:
@@ -1303,14 +1303,14 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile)
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user