Skip to content

Commit d65c312

Browse files
fix(doom): Adjust cursor position for multibyte charsets in menu entry (#424)
* fix(doom): Adjust cursor position for multibyte charsets in menu entry * Update lua/dashboard/theme/doom.lua Co-authored-by: Raphael <glephunter@gmail.com> --------- Co-authored-by: Raphael <glephunter@gmail.com>
1 parent 04a48b2 commit d65c312

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/dashboard/theme/doom.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ local function generate_center(config)
129129
curline = curline + (before > curline and -1 or 1)
130130
end
131131
before = curline
132-
api.nvim_win_set_cursor(config.winid, { curline, col })
132+
133+
-- FIX: #422: In Lua the length of a string is the numbers of bytes not
134+
-- the number of characters.
135+
local curline_str = api.nvim_buf_get_lines(config.bufnr, curline - 1, curline, false)[1]
136+
local delta = curline_str:len() - api.nvim_strwidth(curline_str) - 2
137+
api.nvim_win_set_cursor(config.winid, { curline, col + delta })
133138
end,
134139
})
135140
end, 0)

0 commit comments

Comments
 (0)