summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-02-23 19:32:03 +0100
committerBram Moolenaar <Bram@vim.org>2021-02-23 19:32:03 +0100
commit2c6553498e790604f50016d8435403523a2576d6 (patch)
tree809b32b0baedaa41e837ca2e6c4eedd6272e623d
parent21a83bd53d1fe21c780316c40fdc14d49167d08b (diff)
patch 8.2.2547: "%" command not accurate for big filesv8.2.2547
Problem: "%" command not accurate for big files. Solution: Make it more accurate for files up to 21M lines. (Dominique Pellé, closes #7889)
-rw-r--r--src/normal.c8
-rw-r--r--src/version.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/normal.c b/src/normal.c
index 9fbfadfbc7..d2f41593a0 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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
diff --git a/src/version.c b/src/version.c
index c63e60c3d9..7eb0d057af 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2547,
+/**/
2546,
/**/
2545,