Skip to content

Commit 2c65534

Browse files
committed
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)
1 parent 21a83bd commit 2c65534

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/normal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,9 +4769,11 @@ nv_percent(cmdarg_T *cap)
47694769
{
47704770
cap->oap->motion_type = MLINE;
47714771
setpcmark();
4772-
// Round up, so CTRL-G will give same value. Watch out for a
4773-
// large line count, the line number must not go negative!
4774-
if (curbuf->b_ml.ml_line_count > 1000000)
4772+
// Round up, so 'normal 100%' always jumps at the line line.
4773+
// Beyond 21474836 lines, (ml_line_count * 100 + 99) would
4774+
// overflow on 32-bits, so use a formula with less accuracy
4775+
// to avoid overflows.
4776+
if (curbuf->b_ml.ml_line_count >= 21474836)
47754777
curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L)
47764778
/ 100L * cap->count0;
47774779
else

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2547,
753755
/**/
754756
2546,
755757
/**/

0 commit comments

Comments
 (0)