fix(debug): better way of getting visual selection. See #190

This commit is contained in:
Folke Lemaitre 2024-12-02 20:11:45 +01:00
parent e26ab0ef2c
commit af41cb088d
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -49,8 +49,13 @@ function M.run(opts)
-- Get the lines to run
local lines ---@type string[]
if vim.fn.mode():find("[vV]") then
vim.fn.feedkeys(":", "nx")
local mode = vim.fn.mode()
if mode:find("[vV]") then
if mode == "v" then
vim.cmd("normal! v")
elseif mode == "V" then
vim.cmd("normal! V")
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, {})