fix(dashboard): calculate proper offset when item has no text

This commit is contained in:
Folke Lemaitre 2024-12-02 16:27:36 +01:00
parent 78f44f720b
commit 6e3b9546de
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -695,7 +695,9 @@ function D:update()
end end
end end
if item then if item then
last = { item._.row, (self.lines[item._.row]:find("[%w%d%p]", item._.col + 1) or item._.col + 1) - 1 } local col = self.lines[item._.row]:find("[%w%d%p]", item._.col + 1)
col = col or (item._.col + 1 + (item.indent and (item.indent + 1) or 0))
last = { item._.row, (col or item._.col + 1) - 1 }
end end
vim.api.nvim_win_set_cursor(self.win, last) vim.api.nvim_win_set_cursor(self.win, last)
end, end,
@ -991,6 +993,7 @@ function M.sections.terminal(opts)
end end
return { return {
action = opts.action, action = opts.action,
key = opts.key,
render = function(_, pos) render = function(_, pos)
self:trace("terminal.render") self:trace("terminal.render")
local win = vim.api.nvim_open_win(buf, false, { local win = vim.api.nvim_open_win(buf, false, {
@ -1019,7 +1022,7 @@ function M.sections.terminal(opts)
self.on("Closed", close, self.augroup) self.on("Closed", close, self.augroup)
self:trace() self:trace()
end, end,
text = ("terminal\n"):rep(height - 1), text = ("\n"):rep(height - 1),
} }
end end
end end