Skip to content

Commit

Permalink
Ignore file not found errors when loading org file that is not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Nov 5, 2023
1 parent d1d6eff commit 185f54e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/orgmode/parser/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,18 @@ function File.load(path, callback)
return callback(nil)
end
local category = vim.fn.fnamemodify(path, ':t:r')
utils.readfile(path):next(vim.schedule_wrap(function(content)
return callback(File.from_content(content, category, path, ext == 'org_archive'))
end))
utils
.readfile(path)
:next(vim.schedule_wrap(function(content)
return callback(File.from_content(content, category, path, ext == 'org_archive'))
end))
:catch(function(err)
-- Ignore file not found errors
if vim.startswith(err, 'ENOENT') then
return
end
error(err)
end)
end

---@param content table
Expand Down

0 comments on commit 185f54e

Please sign in to comment.