Skip to content

Commit

Permalink
fix(doom): Never set a negative column cursor position (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
polirritmico committed Jul 14, 2024
1 parent 40ac8bf commit a09d2ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lua/dashboard/theme/doom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ local function generate_center(config)
-- FIX: #422: In Lua the length of a string is the number of bytes not
-- the number of characters.
local curline_str = api.nvim_buf_get_lines(config.bufnr, curline - 1, curline, false)[1]
local offset = col_width - api.nvim_strwidth(curline_str:sub(1, col + 1))
if offset < 0 then
offset = 0
local strwidth = api.nvim_strwidth(curline_str:sub(1, col + 1))
local col_with_offset = col + col_width - strwidth
if col_with_offset < 0 then
col_with_offset = 0
end
api.nvim_win_set_cursor(config.winid, { curline, col + offset })
api.nvim_win_set_cursor(config.winid, { curline, col_with_offset })
end,
})
end, 0)
Expand Down

0 comments on commit a09d2ef

Please sign in to comment.