diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-05-24 15:44:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 15:44:52 +0800 |
commit | cd05fbef170b29083973fd11170d25225feb8bed (patch) | |
tree | 5c5f336651131811a83d27122ebc302eece6e2b7 /runtime/lua | |
parent | c836383d21b6d38ecf59e46e76da55ca97a4fc65 (diff) | |
download | rneovim-cd05fbef170b29083973fd11170d25225feb8bed.tar.gz rneovim-cd05fbef170b29083973fd11170d25225feb8bed.tar.bz2 rneovim-cd05fbef170b29083973fd11170d25225feb8bed.zip |
vim-patch:9.1.0441: getregionpos() can't properly indicate positions beyond eol (#28957)
Problem: getregionpos() can't properly indicate positions beyond eol.
Solution: Add an "eol" flag that enables handling positions beyond end
of line like getpos() does (zeertzjq).
Also fix the problem that a position still has the coladd beyond the end
of the line when its column has been clamped. In the last test case
with TABs at the end of the line the old behavior is obviously wrong.
I decided to gate this behind a flag because returning positions that
don't correspond to actual characters in the line may lead to mistakes
for callers that want to calculate the length of the selected text, so
the behavior is only enabled if the caller wants it.
closes: vim/vim#14838
https://github.com/vim/vim/commit/2b09de910458247b70751928217422c38fd5abf8
Diffstat (limited to 'runtime/lua')
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index e00b2e6acd..f4daacfb7d 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -3599,6 +3599,19 @@ function vim.fn.getregion(pos1, pos2, opts) end --- the offset of the character's first cell not included in the --- selection, otherwise all its cells are included. --- +--- Apart from the options supported by |getregion()|, {opts} also +--- supports the following: +--- +--- eol If |TRUE|, indicate positions beyond +--- the end of a line with "col" values +--- one more than the length of the line. +--- If |FALSE|, positions are limited +--- within their lines, and if a line is +--- empty or the selection is entirely +--- beyond the end of a line, a "col" +--- value of 0 is used for both positions. +--- (default: |FALSE|) +--- --- @param pos1 table --- @param pos2 table --- @param opts? table |