Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #84 , move_jump_target should use characters instead of cells #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lua/hop/jump_target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ function M.move_jump_target(jt, offset_row, offset_cell)

if dcell ~= 0 then
local line = vim.api.nvim_buf_get_lines(jt.buffer, jt.cursor.row - 1, jt.cursor.row, false)[1]
local line_cells = vim.fn.strdisplaywidth(line)
local line_chars = vim.fn.strchars(line)
---@type WindowCell
local new_cell = vim.fn.strdisplaywidth(line:sub(1, jt.cursor.col)) + dcell
if new_cell >= line_cells then
new_cell = line_cells
elseif new_cell < 0 then
new_cell = 0
local new_char = vim.fn.strchars(line:sub(1, jt.cursor.col)) + dcell
if new_char >= line_chars then
new_char = line_chars - 1
elseif new_char < 0 then
new_char = 0
end
jt.cursor.col = vim.fn.byteidx(line, window.cell2char(line, new_cell))
jt.cursor.col = vim.fn.byteidx(line, new_char)
end
end

Expand Down