goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.82k stars 109 forks source link

fix : bug in alpha.press function #155

Closed emsquid closed 1 year ago

emsquid commented 1 year ago

I added a condition to execute a press only when it isn't calling a nil value (because it could try to call a nil value for me)

goolord commented 1 year ago

why can't you just pass function () end instead of nil? this seems superfluous to me

emsquid commented 1 year ago

why can't you just pass function () end instead of nil? this seems superfluous to me

Well to be honest I don't know much about lua, I just tried to fix an error I was facing, if you can fix it better I would appreciate it. Just so you know sometimes cursor_jump_press[cursor_ix] isn't defined and it gives me an error (maybe because the cursor moves on redraw idk), you can try with theta theme, pressing two times the configuration button quickly throw an error.

adoyle-h commented 1 year ago

@goolord This issue can be reproduced.

    local dashboard = require('alpha.themes.dashboard')
    local button = dashboard.button

    require('alpha').setup {
        layout = {
            { type = 'text', val = 'hello', opts = { position = 'center' } },
            {
                type = 'group',
                val = { button('<leader>u', 'test', ':echo "test"<CR>') },
                opts = { spacing = 0 },
            },
        },
    }

Press <CR> twice. It will throw an error.

CleanShot 2022-11-06 at 16 25 40@2x

goolord commented 1 year ago

i see, the bug wasn't well described so i misunderstood. anyways, this doesn't seem like a very good solution to the problem adoyle-h described

goolord commented 1 year ago

https://github.com/goolord/alpha-nvim/commit/a858e4e7b0805835e61fab2b54704450427d47c3 should fix the problem described by @adoyle-h