Skip to content

Commit 480d0be

Browse files
authored
fix(doom): Correct negative offset when resizing terminal (#462)
* refactor(doom): Replace deprecated nvim_buf_get_option * fix(doom): Correct negative offset when resizing terminal
1 parent 5346d02 commit 480d0be

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lua/dashboard/theme/doom.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ local function generate_center(config)
118118
buffer = config.bufnr,
119119
callback = function()
120120
local buf = api.nvim_win_get_buf(0)
121-
if vim.api.nvim_buf_get_option(buf, 'filetype') ~= 'dashboard' then
121+
if vim.api.nvim_get_option_value('filetype', { buf = buf }) ~= 'dashboard' then
122122
return
123123
end
124124

@@ -132,11 +132,14 @@ local function generate_center(config)
132132
end
133133
before = curline
134134

135-
-- FIX: #422: In Lua the length of a string is the numbers of bytes not
135+
-- 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 delta = col_width - api.nvim_strwidth(curline_str:sub(1, col + 1))
139-
api.nvim_win_set_cursor(config.winid, { curline, col + delta })
138+
local offset = col_width - api.nvim_strwidth(curline_str:sub(1, col + 1))
139+
if offset < 0 then
140+
offset = 0
141+
end
142+
api.nvim_win_set_cursor(config.winid, { curline, col + offset })
140143
end,
141144
})
142145
end, 0)

0 commit comments

Comments
 (0)