From 4599c7afffd34624752e53f87863d7fc8a6d9d62 Mon Sep 17 00:00:00 2001 From: My Arcana <47053826+myarcana@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:27:03 +0000 Subject: [PATCH] Fix move_jump_target --- lua/hop/jump_target.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/hop/jump_target.lua b/lua/hop/jump_target.lua index 91b532d..b7f0235 100644 --- a/lua/hop/jump_target.lua +++ b/lua/hop/jump_target.lua @@ -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