summaryrefslogtreecommitdiffstats
path: root/runtime/doc/builtin.txt
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-24 07:48:51 +0200
committerChristian Brabandt <cb@256bit.org>2024-05-24 07:48:51 +0200
commit2b09de910458247b70751928217422c38fd5abf8 (patch)
treed649c131b442e7e3d3aa717ba4ca77de629748b7 /runtime/doc/builtin.txt
parent44cadaa18c1816f7a576f1870790ee01a23c1071 (diff)
patch 9.1.0441: getregionpos() can't properly indicate positions beyond eolv9.1.0441
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: #14838 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/doc/builtin.txt')
-rw-r--r--runtime/doc/builtin.txt15
1 files changed, 14 insertions, 1 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 4177a01811..afd84c11ef 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt* For Vim version 9.1. Last change: 2024 May 22
+*builtin.txt* For Vim version 9.1. Last change: 2024 May 24
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -4348,6 +4348,19 @@ getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
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|)
+
Can also be used as a |method|: >
getpos('.')->getregionpos(getpos("'a"))
<