Describe the bug
The column position of a mark as reported by getmarklist() is off by one.
To Reproduce
Run this shell command:
vim -Nu NONE -i NONE +"sil pu!=['abc', 'def', 'ghi']" +'norm! 2G3|mm1G1|' +'call getmarklist(bufnr("%"))->filter({_,v -> v.mark =~# ".m"})[0].pos->setpos(".")'
This populates a buffer with the text:
abc
def
ghi
Then, it sets the mark m on the character f (third character on second line), and moves the cursor back on the the character a (first character on first line). Finally, it invokes getmarklist() to retrieve the position of the mark m and setpos() to restore the cursor where the mark was set originally (i.e. on the character f).
The cursor is positioned on the character e.
Expected behavior
The cursor is positioned on the character f.
Environment
Additional context
According to :h getmarklist(), the pos key should have the same meaning as for getpos():
pos - a |List| with the position of the mark:
[bufnum, lnum, col, off]
Refer to |getpos()| for more information.
If that's the case, then we should be able to restore the cursor position without having to apply a positive offset on the column number.
Unrelated to this issue, but I've also noticed that getmarklist() can't be used as a method contrary to the similar functions getjumplist() and getchangelist(). Let me know if you want me to open a new issue for that too.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
To summarize, getmarklist() starts indexing the column positions from the index 0, while getpos() starts from 1, which seems inconsistent.
To summarize,
getmarklist()starts indexing the column positions from the index 0, whilegetpos()starts from 1, which seems inconsistent.
Fixed by 8.2.0871.
—
You are receiving this because you commented.