fix: 1-len cursors

This commit is contained in:
əlemi 2024-10-02 02:14:41 +02:00
parent 28b14eb761
commit a3fa3ea743
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -100,9 +100,10 @@ local function register_cursor_handler(controller)
local buffer_id = buffers.map_rev[event.buffer] local buffer_id = buffers.map_rev[event.buffer]
if buffer_id ~= nil then if buffer_id ~= nil then
local hi = user_hl[event.user].hi local hi = user_hl[event.user].hi
local event_finish_2 = event.finish[2] -- TODO can't set the tuple field? need to copy out
if event.start[1] == event.finish[1] and event.start[2] == event.finish[2] then if event.start[1] == event.finish[1] and event.start[2] == event.finish[2] then
-- vim can't draw 0-width cursors, so we always expand them to at least 1 width -- vim can't draw 0-width cursors, so we always expand them to at least 1 width
event.finish[2] = event.finish[2] + 1 event_finish_2 = event.finish[2] + 1
end end
user_hl[event.user].mark = vim.api.nvim_buf_set_extmark( user_hl[event.user].mark = vim.api.nvim_buf_set_extmark(
buffer_id, buffer_id,
@ -112,7 +113,7 @@ local function register_cursor_handler(controller)
{ {
id = user_hl[event.user].mark, id = user_hl[event.user].mark,
end_row = event.finish[1], end_row = event.finish[1],
end_col = event.finish[2], end_col = event_finish_2,
hl_group = hi.bg, hl_group = hi.bg,
virt_text_pos = "right_align", virt_text_pos = "right_align",
sign_text = string.sub(event.user, 0, 1), sign_text = string.sub(event.user, 0, 1),