mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
fix(lua): ensure vim.region truncates to buf range
If vim.region receives a large range outside of the current buffer bounds, it will not check the range ahead of time and loop until neovim exhausts the system memory. Fixes #14743
This commit is contained in:
@@ -349,6 +349,11 @@ function vim.region(bufnr, pos1, pos2, regtype, inclusive)
|
|||||||
vim.fn.bufload(bufnr)
|
vim.fn.bufload(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check that region falls within current buffer
|
||||||
|
local buf_line_count = vim.api.nvim_buf_line_count(bufnr)
|
||||||
|
pos1[1] = math.min(pos1[1], buf_line_count - 1)
|
||||||
|
pos2[1] = math.min(pos2[1], buf_line_count - 1)
|
||||||
|
|
||||||
-- in case of block selection, columns need to be adjusted for non-ASCII characters
|
-- in case of block selection, columns need to be adjusted for non-ASCII characters
|
||||||
-- TODO: handle double-width characters
|
-- TODO: handle double-width characters
|
||||||
local bufline
|
local bufline
|
||||||
|
Reference in New Issue
Block a user