Skip to content

Commit

Permalink
fix: make default mru index independent of section ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
goolord committed Apr 1, 2022
1 parent 20ecf5c commit c4a3b23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lua/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,10 @@ function alpha.start(on_vimenter, conf)
)
vim.api.nvim_win_set_cursor(state.window, cursor_jumps[ix])
end
alpha.redraw = draw
alpha.redraw = function ()
if conf.opts and conf.opts.on_redraw then conf.opts.on_redraw() end
draw()
end
alpha.close = function()
cursor_ix = 1
cursor_jumps = {}
Expand Down
13 changes: 11 additions & 2 deletions lua/alpha/themes/startify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local if_nil = vim.F.if_nil
local fnamemodify = vim.fn.fnamemodify
local filereadable = vim.fn.filereadable

local mru_index = 0

local default_header = {
type = "text",
val = {
Expand Down Expand Up @@ -181,7 +183,9 @@ local section = {
{
type = "group",
val = function()
return { mru(0) }
local x = mru(mru_index)
mru_index = mru_index + 10
return {x}
end,
},
},
Expand All @@ -195,7 +199,9 @@ local section = {
{
type = "group",
val = function()
return { mru(10, vim.fn.getcwd()) }
local x = mru(mru_index, vim.fn.getcwd())
mru_index = mru_index + 10
return {x}
end,
opts = { shrink_margin = false },
},
Expand Down Expand Up @@ -228,6 +234,9 @@ local config = {
opts = {
margin = 3,
redraw_on_resize = false,
on_redraw = function ()
mru_index = 0
end,
setup = function()
vim.cmd([[
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
Expand Down

0 comments on commit c4a3b23

Please sign in to comment.