You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is recently a new function in neovim called getregionpos which I believe will be better to use than the existing buffer_get_selection(). Also has the benefit of existing tests in neovim, etc. One thing I'm not sure about will be the 'reverse' part, but I suspect it will still be easier to just use vim.fn.getregionpos() and work out the reverse flag.
getregionpos() takes arguments but buffer_get_selection() does not
getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
Same as |getregion()|, but returns a list of positions
describing the buffer text segments bound by {pos1} and
{pos2}.
The segments are a pair of positions for every line:
[[{pos_start}, {pos_end}], ...]
The position is a |List| with four numbers:
[bufnum, lnum, col, off]
"bufnum" is the buffer number.
"lnum" and "col" are the position in the buffer. The first
column is 1.
The "off" number is zero, unless 'virtualedit' is used. Then
it is the offset in screen columns from the start of the
character. E.g., a position within a <Tab> or after the last
character.
Can also be used as a |method|: >
getpos('.')->getregionpos(getpos("'a"))
<
It's not identical. My thinking is that you would call it with something like vim.fn.getpos("'>") and vim.fn.getpos("'>") as the visual selection start/end positions to get back most of the coordinates you are currently trying to compute yourself. Probably the majority of buffer_get_selection()'s logic would be replaced by a call to vim.fn.getregionpos(). But ya, would need to test to make sure it can be used.
There is recently a new function in neovim called getregionpos which I believe will be better to use than the existing buffer_get_selection(). Also has the benefit of existing tests in neovim, etc. One thing I'm not sure about will be the 'reverse' part, but I suspect it will still be easier to just use vim.fn.getregionpos() and work out the reverse flag.
See vim/vim#14617
We will have to wait at least for 0.11 release (October 31, 2024) for it to be available though.
The text was updated successfully, but these errors were encountered: