VCS: Fix off-by-one line in blame

Line is blockNumber()+1. When executing blame, the cursor jumps to one line
above the selected line.

Change-Id: Ia28b6c5a353ee979fae3f463b864d1409d9649cd
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-07-01 23:09:43 +03:00
committed by Orgad Shaneh
parent 65a4333f2c
commit eb711d9864

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->textCursor().blockNumber();
const int cursorLine = eda->textCursor().blockNumber() + 1;
auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget());
if (edw) {
const int firstLine = edw->firstVisibleBlockNumber();
const int lastLine = edw->lastVisibleBlockNumber();
const int firstLine = edw->firstVisibleBlockNumber() + 1;
const int lastLine = edw->lastVisibleBlockNumber() + 1;
if (firstLine <= cursorLine && cursorLine < lastLine)
return cursorLine;
return edw->centerVisibleBlockNumber();
return edw->centerVisibleBlockNumber() + 1;
}
return cursorLine;
}