From ff039bb024ca0a8753c6591fa8cb98312090f739 Mon Sep 17 00:00:00 2001 From: Volodymyr Chernetskyi <19735328+chernetskyi@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:53:40 +0200 Subject: perf(hightlight): compute only bounds for non-blockwise highlights Problem: vim.hl.range() computes a segment for every selected line, then discards all but the outer endpoints for characterwise and linewise highlights. This makes highlighting large yanks and puts unnecessarily expensive. Solution: Use getregionpos() with bounds=true for these highlights. Also use bounds in the keymap example that only needs the first and last selected lines. AI-assisted --- runtime/lua/vim/keymap.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/keymap.lua') diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index 7451f42ad4..061d3340fe 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -39,9 +39,10 @@ local keymap = {} --- type = 'v', --- exclusive = false, --- eol = false, +--- bounds = true, --- }) --- local line1 = region[1][1][2] ---- local line2 = region[#region][1][2] +--- local line2 = region[1][2][2] --- vim.print({ line1, line2 }) --- end) --- -- cgit