variar / klogg

Really fast log explorer based on glogg project
https://klogg.filimonov.dev
GNU General Public License v3.0
2.37k stars 208 forks source link

fix: bottom view line in overview is now calculated correctly. #707

Closed s-g-stavely closed 4 days ago

s-g-stavely commented 9 months ago

I noticed that when viewing files, the "view lines" shown on the overview did not line up with the actual lines that were being viewed. Instead, one of the lines would always remain near the top of the file.

This is because this change added some extra brackets to Overview::getViewLines() that changed the order of operations in the calculation of bottom. I've fixed up the order of operations for this calculation.

Original working code: bottom = (int)((qint64)top + nbLines_.get() * height_ / linesInFile_.get());

Code with incorrect order of operations: bottom = static_cast<int>( ( static_cast<unsigned>( top ) + nbLines_.get() ) * height_ / ( linesInFile_.get() ) );

Fixed code: bottom = top + static_cast<int>( nbLines_.get() * height_ / ( linesInFile_.get() ) );

variar commented 4 days ago

Tnanks!