{{ message }}
Conversation
Member
Problem: setpos() and setcharpos() update the wrong logical Visual mark
when a Visual selection was made in reverse (numEricL).
Solution: Resolve the Visual marks to buffer-relative endpoints before
updating them, preserve the other endpoint when deleting a mark,
and let getmark() order crossed endpoints (zhanglangning).
fixes: vim#19049
AI-assisted: Codex
Signed-off-by: zhanglangning <zln1905391059@163.com>
Boulea7
force-pushed
the
fix/19049-visual-marks
branch
from
August 13, 2026 03:20
e218171 to
cc83269
Compare
Author
|
You're right. Your example exposed a bug in the clamping logic: moving I added your linewise case and the inverse crossing case; both now preserve the full range. |
Boulea7
marked this pull request as draft
August 13, 2026 04:02
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
For a reversed Visual selection,
getpos("'<")reports the buffer-relative start whilesetpos("'<", ...)updates the endpoint associated with the selection direction.setcharpos()follows the same path, so the get/set APIs are inconsistent. Fixes #19049.Solution
Resolve
'<and'>to their logical buffer-relative endpoints before updating them. Crossing the other endpoint now changes the stored order without changing that other endpoint;getmark()continues to return the marks in logical order. Deleting either endpoint preserves the remaining endpoint so the deleted mark can be recreated.Update
builtin.txtand add regression coverage for forward and reversed selections, column and line crossings in both directions, deletion and recreation, active Visual mode, independent initialization, andsetcharpos().Tests
make -C src -j2make -C src/testdir -W test_marks.vim TEST_FILTER=Test_setpos test_marks.resmake -C src/testdir -j3 -W test_marks.vim -W test_visual.vim -W test_codestyle.vim test_marks.res test_visual.res test_codestyle.resgit diff --check origin/master..HEADFull test counts:
test_marks14/14,test_visual81/81,test_codestyle5/5.AI-assisted: Codex