diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-02-23 20:14:27 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-02-23 20:24:41 -0500 |
commit | 9b5e3ba32d370a4f3e26acba2c052d84e2359316 (patch) | |
tree | 263f9e92ff8aafdc24691b49ad09b5d2adbe8589 /src/nvim/normal.c | |
parent | 0450e155d48cb2d8a73358e193931d8966a9d2e0 (diff) | |
download | rneovim-9b5e3ba32d370a4f3e26acba2c052d84e2359316.tar.gz rneovim-9b5e3ba32d370a4f3e26acba2c052d84e2359316.tar.bz2 rneovim-9b5e3ba32d370a4f3e26acba2c052d84e2359316.zip |
vim-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 vim/vim#7889)
https://github.com/vim/vim/commit/2c6553498e790604f50016d8435403523a2576d6
N/A patches for version.c:
vim-patch:8.2.2545: errors and crash when terminal window is zero height
Problem: Errors and crash when terminal window is zero height. (Leonid V.
Fedorenchik)
Solution: Do not resize when width or height is zero. (closes vim/vim#7890)
https://github.com/vim/vim/commit/eba13e4ea28f133ff65f6b426428f49a9bd711b0
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8f22243348..1e15ded643 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5792,16 +5792,20 @@ static void nv_percent(cmdarg_T *cap) } else { cap->oap->motion_type = kMTLineWise; 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 + } else { curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * cap->count0 + 99L) / 100L; - if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) + } + if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; + } beginline(BL_SOL | BL_FIX); } } else { // "%" : go to matching paren |