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)
2c6553498e

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)
eba13e4ea2
This commit is contained in:
Jan Edmund Lazo
2021-02-23 20:14:27 -05:00
parent 0450e155d4
commit 9b5e3ba32d

View File

@@ -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