ui: adapt scroll target value in code single file mode as workaround when view scrolls below last line
This commit is contained in:
@@ -195,6 +195,19 @@ bool QtCodeFileSingle::requestScroll(
|
||||
double percentA = double(lineNumber - 1) / m_area->getEndLineNumber();
|
||||
double percentB = endLineNumber ? double(endLineNumber - 1) / m_area->getEndLineNumber() : 0.0f;
|
||||
|
||||
// fix percentages wrong when code area is scrollable beyond last line due to some unknown bug
|
||||
{
|
||||
int totalHeight = m_area->sizeHint().height();
|
||||
int totalLineHeight = m_area->totalLineHeight();
|
||||
|
||||
if (std::abs(totalHeight - totalLineHeight) > 100)
|
||||
{
|
||||
double factor = totalLineHeight / double(totalHeight);
|
||||
percentA *= factor;
|
||||
percentB *= factor;
|
||||
}
|
||||
}
|
||||
|
||||
ensurePercentVisibleAnimated(percentA, percentB, animated, target);
|
||||
|
||||
m_scrollRequested = true;
|
||||
|
||||
Reference in New Issue
Block a user