Skip to content

Commit

Permalink
Merge pull request hadronized#279 from ii14/fix_col_range_error
Browse files Browse the repository at this point in the history
fix: fix "col value outside range" error
  • Loading branch information
hadronized authored Jul 22, 2022
2 parents e23fdb8 + da3affb commit ced6c94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/hop/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ local function set_unmatched_lines(buf_handle, hl_ns, top_line, bottom_line, cur
start_col = cursor_pos[2]
elseif direction == hint.HintDirection.BEFORE_CURSOR then
end_line = bottom_line - 1
if cursor_pos[2] ~= 0 then end_col = cursor_pos[2] + 1 end
if cursor_pos[2] ~= 0 then end_col = cursor_pos[2] end
end

if current_line_only then
Expand Down
4 changes: 3 additions & 1 deletion lua/hop/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ function M.get_window_context(multi_windows)
-- Generate contexts of windows
local cur_hwin = vim.api.nvim_get_current_win()
local cur_hbuf = vim.api.nvim_win_get_buf(cur_hwin)
local cur_col = vim.fn.strwidth(vim.api.nvim_get_current_line():sub(1, vim.fn.col('.')))

all_ctxs[#all_ctxs + 1] = {
hbuf = cur_hbuf,
contexts = { window_context(cur_hwin, {vim.fn.getcurpos()[2], vim.fn.getcurpos()[5]} ) },
contexts = { window_context(cur_hwin, {vim.fn.line('.'), cur_col} ) },
}

if not multi_windows then
Expand Down

0 comments on commit ced6c94

Please sign in to comment.