Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(render): show message if not yet committed #707

Merged
merged 2 commits into from
Apr 15, 2023
Merged

fix(render): show message if not yet committed #707

merged 2 commits into from
Apr 15, 2023

Conversation

futsuuu
Copy link
Contributor

@futsuuu futsuuu commented Mar 31, 2023

When using a local plugin that has not yet been commited, the following error occurs when trying to view plugin information.

Error executing vim.schedule lua callback: ...local/share/nvim/lazy/lazy.nvim/lua/lazy/view/render.lua:502: attempt to index field 'commit' (a nil value)
stack traceback:
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/view/render.lua:502: in function 'details'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/view/render.lua:422: in function 'plugin'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/view/render.lua:239: in function 'section'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/view/render.lua:71: in function 'update'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/view/init.lua:142: in function 'fn'
        ...tsuuu/.local/share/nvim/lazy/lazy.nvim/lua/lazy/util.lua:72: in function <...tsuuu/.local/share/nvim/lazy/lazy.nvim/lua/lazy/util.lua:71>

So make it show No commits yet if git.commit is nil.

if git.commit then
table.insert(props, { "commit", git.commit:sub(1, 7), "LazyCommit" })
else
table.insert(props, { "commit", "No commits yet" })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to just not show the commit here in this case? So just drop the else part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case, git.commit was nil but git.branch was not nil, so I thought it would be better to show the commit as well, just in case.
However, it is not always the case that git.commit does not become nil in other cases, so I should certainly drop the else part.

@futsuuu futsuuu requested a review from folke April 1, 2023 12:57
@folke folke merged commit b7a1a0f into folke:main Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants