Mercurial > vim
changeset 24010:c9849ed1ce05 v8.2.2547
patch 8.2.2547: "%" command not accurate for big files
Commit: https://github.com/vim/vim/commit/2c6553498e790604f50016d8435403523a2576d6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 23 19:32:03 2021 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 23 Feb 2021 19:45:04 +0100 |
parents | 97041a388b6e |
children | eabefc3d2c80 |
files | src/normal.c src/version.c |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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