Skip to content

Commit a09d2ef

Browse files
authored
fix(doom): Never set a negative column cursor position (#470)
1 parent 40ac8bf commit a09d2ef

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lua/dashboard/theme/doom.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ local function generate_center(config)
135135
-- FIX: #422: In Lua the length of a string is the number of bytes not
136136
-- the number of characters.
137137
local curline_str = api.nvim_buf_get_lines(config.bufnr, curline - 1, curline, false)[1]
138-
local offset = col_width - api.nvim_strwidth(curline_str:sub(1, col + 1))
139-
if offset < 0 then
140-
offset = 0
138+
local strwidth = api.nvim_strwidth(curline_str:sub(1, col + 1))
139+
local col_with_offset = col + col_width - strwidth
140+
if col_with_offset < 0 then
141+
col_with_offset = 0
141142
end
142-
api.nvim_win_set_cursor(config.winid, { curline, col + offset })
143+
api.nvim_win_set_cursor(config.winid, { curline, col_with_offset })
143144
end,
144145
})
145146
end, 0)

0 commit comments

Comments
 (0)