variar / klogg

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

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

Open s-g-stavely opened 4 months ago

s-g-stavely commented 4 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() ) );