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

Improve error handling and stability #8

Closed
wants to merge 3 commits into from

Conversation

atiladefreitas
Copy link

When trying to close an buffer while using slimline.nvim some errors message appears to me.

Screenshot from 2024-08-27 20-24-05

For closing an buffer I've setted up the following action:

vim.keymap.set("n", "<leader>cc", ":bd<cr>", { desc = "close buffer" })

So, with that, I united my desire to be part of the neovim contributor community and took the liberty of opening this PR with the following adjustments:

  1. Enhanced error handling in the render() function to prevent statusline crashes.
  2. Implemented additional checks in concat_components() to handle potential failures in individual components.
  3. Added buffer and window validity checks in the render() and refresh().
  4. Modified the refresh() function to ignore E315 errors while still handling other potential issues.
  5. Provided a fallback to a simple statusline when errors occur during rendering or refreshing.

- Add error handling to render() and concat_components()
- Implement buffer validity check
- Provide fallback statusline on errors- Log errors for easier debugging
@sschleemilch
Copy link
Owner

sschleemilch commented Aug 28, 2024

Thank you for your contribution. I will have a look today evening probably.
But I was wondering whether we could fix the root cause instead?
Sure, error handling is great and I like your improvements there.
It seems that in the end it is about the autocommand DiagnositcsChanged that I probably did not understand when it is being triggered. My assumption was that we are in a valid buffer when it is fired. This also links to issue #1 where the same autocommand seems to crash.
Could we try to make checks there whether we should trigger a refresh?

Also quite weird about the buffer closing, I can do :bd just fine without any problems but maybe it is about the LSP attached? Not sure...

I think I will remove the DiagnosticsChanged autocommand for now because I am not even sure if we need it and it seems to be the error source of your and the problem of #1

@sschleemilch
Copy link
Owner

I just pushed disabling the DiagnosticChanged autocommand. Could you check whether that fixes your problem?

@atiladefreitas
Copy link
Author

Hey, just updated here and everything went beautifully.

and as you saind before, the error is actually related to LSP. So basically I tried to kill an ant with a bazooka 😅

@sschleemilch
Copy link
Owner

Hey, just updated here and everything went beautifully.

and as you saind before, the error is actually related to LSP. So basically I tried to kill an ant with a bazooka 😅

Great to hear. Should we close this one then?

@atiladefreitas
Copy link
Author

Great to hear. Should we close this one then?

Go for it buddy

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