mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
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
2b09de9104
This commit is contained in:
@@ -4435,6 +4435,19 @@ M.funcs = {
|
||||
If the "off" number of an ending position is non-zero, it is
|
||||
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|)
|
||||
]=],
|
||||
name = 'getregionpos',
|
||||
params = { { 'pos1', 'table' }, { 'pos2', 'table' }, { 'opts', 'table' } },
|
||||
|
Reference in New Issue
Block a user