Skip to content

Commit

Permalink
fix(doom): Adjust cursor position for multibyte charsets in menu entry (
Browse files Browse the repository at this point in the history
#424)

* fix(doom): Adjust cursor position for multibyte charsets in menu entry

* Update lua/dashboard/theme/doom.lua

Co-authored-by: Raphael <[email protected]>

---------

Co-authored-by: Raphael <[email protected]>
  • Loading branch information
polirritmico and glepnir authored Feb 12, 2024
1 parent 04a48b2 commit d65c312
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/dashboard/theme/doom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ local function generate_center(config)
curline = curline + (before > curline and -1 or 1)
end
before = curline
api.nvim_win_set_cursor(config.winid, { curline, col })

-- FIX: #422: In Lua the length of a string is the numbers of bytes not
-- the number of characters.
local curline_str = api.nvim_buf_get_lines(config.bufnr, curline - 1, curline, false)[1]
local delta = curline_str:len() - api.nvim_strwidth(curline_str) - 2
api.nvim_win_set_cursor(config.winid, { curline, col + delta })
end,
})
end, 0)
Expand Down

0 comments on commit d65c312

Please sign in to comment.