diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-09-15 10:46:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-15 10:46:47 +0800 |
| commit | aed60b8a53bc59323d15468295f720cccfa6280b (patch) | |
| tree | 0341cb821771bf2cfaa3e3ffe7a72b61ac2b938a /runtime/lua/vim/provider/python.lua | |
| parent | daeb69ef93d823ddb420b3b127296f8df59df542 (diff) | |
| download | rneovim-aed60b8a53bc59323d15468295f720cccfa6280b.tar.gz rneovim-aed60b8a53bc59323d15468295f720cccfa6280b.tar.bz2 rneovim-aed60b8a53bc59323d15468295f720cccfa6280b.zip | |
vim-patch:9.2.1108: Scrolling recomputes the height of every visible line (#41920)
Problem: When scrolling, comp_botline() recomputes the display height of
every line in the window on each cursor movement, which is
slower than necessary.
Solution: Reuse the line heights computed for the previous redraw, stored
in w_lines[], the same way curs_rows() already does. (Julien Voisin).
comp_botline() computes w_botline by calling plines_correct_topline() for
every line from the top (or cursor) to the bottom of the window. This walks
every character of every line to measure its display width, and it runs on
every scroll. When the display is up to date the heights are already known
in w_lines[].wl_size and are equal to what plines() would return, so they
can be reused, avoiding the per-line width computation. The cache is only
trusted when redrawing, the buffer was not changed, no "$" is displayed and
w_lines[] starts at or above w_topline; otherwise the previous computation
is used.
Benchmark: 1500 real keystrokes sent to a terminal Vim scrolling a 60000-line
syntax-highlighted C file in a 120x40 window. Instructions retired were
measured with "perf stat", with the constant startup cost subtracted;
run-to-run variation was under 0.01%.
instructions per key
command baseline patched change
j (line down) 252883 117800 -53%
CTRL-E (view down) 210580 114017 -46%
V then j (visual) 320142 184959 -42%
CTRL-D (half page) 634489 585040 -8%
CTRL-F (full page) 1179034 1173068 -1%
k (line up) 4289 4289 0%
The same test without syntax highlighting drops "j" from 217149 to 116598
instructions per key (-46%), and on a file of long wrapped lines from 374952
to 175579 (-53%).
The win scales with how much of the window is reused: a line- or view-scroll
keeps all but one line, a half page keeps half, and a full page or an upward
scroll reuse nothing, so those are unchanged.
closes: vim/vim#21207
https://github.com/vim/vim/commit/6e67c47e6edd163706345dcf84f305f128583396
Co-authored-by: Julien Voisin <julien.voisin@dustri.org>
Diffstat (limited to 'runtime/lua/vim/provider/python.lua')
0 files changed, 0 insertions, 0 deletions