Skip to content

Commit

Permalink
Merge pull request hadronized#254 from phaazon/fix/before-cursor-virt…
Browse files Browse the repository at this point in the history
…ualedit

Fix BEFORE_CURSOR virtual edit.
  • Loading branch information
hadronized authored Jun 21, 2022
2 parents a2730ef + 092ab3f commit a3c94b8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/hop/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,25 @@ local function apply_dimming(buf_handle, hl_ns, top_line, bottom_line, cursor_po
end_line = cursor_pos[1]
end
end

local extmark_options = {
end_line = end_line,
hl_group = 'HopUnmatched',
hl_eol = true,
priority = prio.DIM_PRIO
}
if end_col then extmark_options.end_col = end_col end

if end_col then
local current_line = vim.api.nvim_buf_get_lines(buf_handle, cursor_pos[1] - 1, cursor_pos[1], true)[1]
local current_width = vim.fn.strdisplaywidth(current_line)

if end_col > current_width then
end_col = current_width - 1
end

extmark_options.end_col = end_col
end

vim.api.nvim_buf_set_extmark(buf_handle, hl_ns, start_line, start_col,
extmark_options)
end
Expand Down

0 comments on commit a3c94b8

Please sign in to comment.