Merge pull request #26649 from neovim/backport-26648-to-release-0.9

[Backport release-0.9] fix(api): don't set coladd of mark
This commit is contained in:
zeertzjq 2023-12-19 08:15:22 +08:00 committed by GitHub
commit f538e4fd01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -944,7 +944,7 @@ bool set_mark(buf_T *buf, String name, Integer line, Integer col, Error *err)
}
}
assert(INT32_MIN <= line && line <= INT32_MAX);
pos_T pos = { (linenr_T)line, (int)col, (int)col };
pos_T pos = { (linenr_T)line, (int)col, 0 };
res = setmark_pos(*name.data, &pos, buf->handle, NULL);
if (!res) {
if (deleting) {

View File

@ -799,11 +799,13 @@ describe('api/buf', function()
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
eq(true, curbufmeths.set_mark('z', 1, 1, {}))
eq({1, 1}, curbufmeths.get_mark('z'))
eq({0, 1, 2, 0}, funcs.getpos("'z"))
end)
it('works with file/uppercase marks', function()
curbufmeths.set_lines(-1, -1, true, {'a', 'bit of', 'text'})
eq(true, curbufmeths.set_mark('Z', 3, 1, {}))
eq({3, 1}, curbufmeths.get_mark('Z'))
eq(true, curbufmeths.set_mark('Z', 3, 2, {}))
eq({3, 2}, curbufmeths.get_mark('Z'))
eq({curbuf().id, 3, 3, 0}, funcs.getpos("'Z"))
end)
it('fails when invalid marks names are used', function()
eq(false, pcall(curbufmeths.set_mark, '!', 1, 0, {}))