From 4ec474ed795527e96f889fc93e77714e9ed9e392 Mon Sep 17 00:00:00 2001 From: Volodymyr Chernetskyi Date: Sat, 12 Sep 2026 16:27:08 +0200 Subject: fix(range): use the preceding line for inclusive end marks #41880 Problem: Converting an exclusive end at column zero moves to the preceding row but calculates the inclusive column from the original row's text. Solution: Read the preceding line after decrementing the row. Cover adjacent lines with unequal lengths. AI-assisted --- runtime/lua/vim/range.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/range.lua') diff --git a/runtime/lua/vim/range.lua b/runtime/lua/vim/range.lua index 9f11f30d32..3ec5c2355c 100644 --- a/runtime/lua/vim/range.lua +++ b/runtime/lua/vim/range.lua @@ -153,6 +153,7 @@ local function to_inclusive_pos(buf, row, col) col = col + vim.str_utf_start(line, col) - 1 elseif col == 0 and row > 0 then row = row - 1 + line = util.get_line(buf, row) col = #line > 0 and #line + vim.str_utf_start(line, #line) - 1 or 0 end -- cgit