When visual selection is reversed (the cursor is at the start of the selection) the getpos and setpos functions do not operate on the same visual mark.
The reproducer visually selects with the cursor at the left side of the selection. The first visual mark '< is modified with getpos() and setpos() by incrementing the column by 1. Then getpos() shows first visual mark unchanged, but the last visual mark '> has instead been updated.
vim -u NONE -S repro.txt
getpos() and setpos() should be consistent with the visual marks.
" Expected output: " first visual mark before and after: [0, 1, 1, 0] -> [0, 1, 2, 0] " last visual mark before and after: [0, 1, 7, 0] -> [0, 1, 7, 0] " Actual output: " first visual mark before and after: [0, 1, 1, 0] -> [0, 1, 1, 0] " last visual mark before and after: [0, 1, 7, 0] -> [0, 1, 2, 0]
9.1 Included patches: 1-16, 647, 678, 697
WSL ubuntu 24.04
windows terminal
xterm-256color
bash
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Pasting the script here for easier reproduction:
" invoke this script with "vim -u NONE -S repro.vim" " setup call append(0, "hello world") call cursor(1,1) execute "normal! vwo\<esc>" " get positions of visual marks before modification let first_visual_before = getpos("'<") let last_visual_before = getpos("'>") " modify the first visual mark's column, not changing the relative order let pos = getpos("'<") let pos[2] += 1 call setpos("'<", pos) " get positions of visual marks after modification let first_visual_after = getpos("'<") let last_visual_after = getpos("'>") echom "first visual mark before and after: " . string(first_visual_before) . " -> " . string(first_visual_after) echom "last visual mark before and after: " . string(last_visual_before) . " -> " . string(last_visual_after)
" Expected output: " first visual mark before and after: [0, 1, 1, 0] -> [0, 1, 2, 0] " last visual mark before and after: [0, 1, 7, 0] -> [0, 1, 7, 0] " Actual output: " first visual mark before and after: [0, 1, 1, 0] -> [0, 1, 1, 0] " last visual mark before and after: [0, 1, 7, 0] -> [0, 1, 2, 0]
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()