From 70d4b899928d72ec9ab7961f69ae47fd24b8c3c4 Mon Sep 17 00:00:00 2001 From: Ben Lubas <56943754+benlubas@users.noreply.github.com> Date: Fri, 31 May 2024 15:36:34 -0400 Subject: [PATCH] fix(dirman): swapfile error when opening index.norg (#1451) --- lua/neorg/modules/core/dirman/module.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/neorg/modules/core/dirman/module.lua b/lua/neorg/modules/core/dirman/module.lua index c39027e54..b2db4cc65 100644 --- a/lua/neorg/modules/core/dirman/module.lua +++ b/lua/neorg/modules/core/dirman/module.lua @@ -497,7 +497,14 @@ module.on_event = function(event) end end - vim.cmd.edit(index_path:cmd_string()) + local ok, _ = pcall(vim.cmd.edit, index_path:cmd_string()) + if not ok then + log.warn( + ("Failed to edit file %s. This can result from vim finding a swapfile. If that was the case, ignore this warning."):format( + index_path + ) + ) + end return end