[vim/vim] ensure consistency between setpos() and getpos() for reversed visual selections (PR #19070)

10 views
Skip to first unread message

Eric Larson

unread,
Jan 2, 2026, 4:58:50 PM (4 days ago) Jan 2
to vim/vim, Subscribed

Addresses issue #19049.

Problem

When a visual selection is reversed (the cursor is at the start of the selection), getpos() and setpos() operate inconsistently on the visual marks '< and '>.

When setmark_pos() in src/mark.c sets visual marks, it assigns to vi_start or vi_end without checking their relative order. This is in contrast to getmark_buf_fnum() which returns based on relative order.

Solution

This patch applies the logic found in getmark_buf_fnum() to setmark_pos() so that vim function setpos() updates the leftmost/rightmost marks on '< and '> respectively.


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

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

Commit Summary

  • 5bcff34 reverse visual selection consistency fix

File Changes

(1 file)

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/19070@github.com>

Eric Larson

unread,
Jan 2, 2026, 7:27:26 PM (3 days ago) Jan 2
to vim/vim, Push

@numEricL pushed 2 commits.

  • a212599 Revert "reverse visual selection consistency fix"
  • e8e99ad Clarify visual mark behavior in getpos(), setpos()


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19070/before/5bcff345dbf6f751e587a248bc3b895990edc8f7/after/e8e99ad255a559006d490554f62650bc06650d0b@github.com>

Eric Larson

unread,
Jan 2, 2026, 7:34:48 PM (3 days ago) Jan 2
to vim/vim, Push

@numEricL pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19070/before/e8e99ad255a559006d490554f62650bc06650d0b/after/b2da7cc1f626b1db25984855c8ab529fad299388@github.com>

zeertzjq

unread,
Jan 2, 2026, 7:47:00 PM (3 days ago) Jan 2
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#19070)

There is another typo "reltaive"


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/19070/c3706545762@github.com>

Christian Brabandt

unread,
Jan 3, 2026, 5:49:47 AM (3 days ago) Jan 3
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -4879,6 +4879,10 @@ getpos({expr})						*getpos()*
 		within the line.  To get the character position in the line,
 		use |getcharpos()|.
 
+		The visual marks '< and '> refer to the beginning and end of
+		the visual selection relative to the buffer. Note that this
+		differs from |setpos()|, where they are reltaive to the cursor.
⬇️ Suggested change
-		differs from |setpos()|, where they are reltaive to the cursor.
+		differs from |setpos()|, where they are relative to the cursor.


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/19070/review/3624298445@github.com>

Christian Brabandt

unread,
Jan 3, 2026, 5:51:57 AM (3 days ago) Jan 3
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19070)

Likely too many downstream breaks would result from ensuring consistency, instead clarify behavior in docs.

I agree it is a backwards incompatible change, but I think we should still change this for consistency reasons. I can merge the documentation update now, but I think we should fix this after the 9.2 release.


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/19070/c3706970596@github.com>

Eric Larson

unread,
Jan 3, 2026, 11:19:25 AM (3 days ago) Jan 3
to vim/vim, Push

@numEricL pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19070/before/b2da7cc1f626b1db25984855c8ab529fad299388/after/d05bea1d527edfbc4b169280a09ac89f411e5ee9@github.com>

Christian Brabandt

unread,
Jan 3, 2026, 11:50:36 AM (3 days ago) Jan 3
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19070)

thanks, I tried to make it a bit clearer and have added a few more help text references and also fixed a typo while at it.


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/19070/c3707190199@github.com>

Christian Brabandt

unread,
Jan 3, 2026, 11:50:59 AM (3 days ago) Jan 3
to vim/vim, Subscribed

Closed #19070 via 93eb081.


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/19070/issue_event/21836954906@github.com>

Reply all
Reply to author
Forward
0 new messages