[vim/vim] getregionpos() can't properly indicate positions beyond eol (PR #14838)

8 views
Skip to first unread message

zeertzjq

unread,
May 24, 2024, 12:00:12 AMMay 24
to vim/vim, Subscribed

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.

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.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14838

Commit Summary

  • ff4dc66 getregionpos() can't properly indicate positions beyond eol

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14838@github.com>

Christian Brabandt

unread,
May 24, 2024, 1:49:02 AMMay 24
to vim/vim, Subscribed

thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14838/c2128584956@github.com>

Christian Brabandt

unread,
May 24, 2024, 1:53:11 AMMay 24
to vim/vim, Subscribed

Closed #14838 via 2b09de9.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14838/issue_event/12919255998@github.com>

Justin M. Keyes

unread,
May 24, 2024, 11:44:38 AMMay 24
to vim/vim, Subscribed

@justinmk commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -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.

Was this intentionally chosen instead of v:maxcol ?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14838/review/2077284531@github.com>

zeertzjq

unread,
May 24, 2024, 4:33:07 PMMay 24
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -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.

This is consistent with getpos() etc.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14838/review/2077932958@github.com>

Reply all
Reply to author
Forward
0 new messages