mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix(scratch): weirdness with visual selection and inclusive/exclusive. See #190
This commit is contained in:
parent
1aa4392f2c
commit
f955f082e0
1 changed files with 6 additions and 1 deletions
|
@ -58,7 +58,12 @@ function M.run(opts)
|
|||
end
|
||||
local from = vim.api.nvim_buf_get_mark(buf, "<")
|
||||
local to = vim.api.nvim_buf_get_mark(buf, ">")
|
||||
lines = vim.api.nvim_buf_get_text(buf, from[1] - 1, from[2], to[1] - 1, to[2] + 1, {})
|
||||
|
||||
-- for some reason, sometimes the column is off by one
|
||||
-- see: https://github.com/folke/snacks.nvim/issues/190
|
||||
local col_to = math.min(to[2] + 1, #vim.api.nvim_buf_get_lines(buf, to[1] - 1, to[1], false)[1])
|
||||
|
||||
lines = vim.api.nvim_buf_get_text(buf, from[1] - 1, from[2], to[1] - 1, col_to, {})
|
||||
-- Insert empty lines to keep the line numbers
|
||||
for _ = 1, from[1] - 1 do
|
||||
table.insert(lines, 1, "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue