0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2547: "%" command not accurate for big files

Problem:    "%" command not accurate for big files.
Solution:   Make it more accurate for files up to 21M lines. (Dominique Pellé,
            closes #7889)
This commit is contained in:
Bram Moolenaar
2021-02-23 19:32:03 +01:00
parent 21a83bd53d
commit 2c6553498e
2 changed files with 7 additions and 3 deletions

View File

@@ -4769,9 +4769,11 @@ nv_percent(cmdarg_T *cap)
{
cap->oap->motion_type = MLINE;
setpcmark();
// Round up, so CTRL-G will give same value. Watch out for a
// large line count, the line number must not go negative!
if (curbuf->b_ml.ml_line_count > 1000000)
// Round up, so 'normal 100%' always jumps at the line line.
// Beyond 21474836 lines, (ml_line_count * 100 + 99) would
// overflow on 32-bits, so use a formula with less accuracy
// to avoid overflows.
if (curbuf->b_ml.ml_line_count >= 21474836)
curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L)
/ 100L * cap->count0;
else