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: supress swap file errors #1456

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Conversation

benlubas
Copy link
Contributor

@benlubas benlubas commented Jun 7, 2024

#1451 caught an error caused by swap files and produced an error message that heavily suggested the error was caused by swap and could be ignored when that was never confirmed. Some concern was raised about this approach, and an additional cases of the same bug was found...

So this PR checks the error message (via pattern match) to confirm that a swap error was the cause of vim.cmd.edit failing, and in these cases eats the error message. It's okay (and I'd say preferred) to eat this error b/c a lengthy swap message will pop up on screen for the user, so users will not be confused about what's happening.

In case the error is not caused be swap, it's now re-raised with the exact error message.

#1451 handled the edit call in :Neorg index, this pr additionally handles a call in the hop module when following a link that's opened in nvim.

@@ -53,13 +53,14 @@ local Path = require("pathlib")

local neorg = require("neorg.core")
local log, modules, utils = neorg.log, neorg.modules, neorg.utils
local dirman_utils
Copy link
Member

Choose a reason for hiding this comment

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

If this variable is only used once, then is there a point of creating it here? I'd say YAGNI in this case :p

Copy link
Contributor Author

@benlubas benlubas Jun 7, 2024

Choose a reason for hiding this comment

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

I just think it's so much cleaner this way, and I just do that everywhere.

+ smaller diffs in the future if you are to add something that uses dirman_utils and want to pull it into a variable then.

You've also already merged code that does this :P

@vhyrro vhyrro merged commit 4420ddc into nvim-neorg:main Jun 11, 2024
5 checks passed
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