Skip to content

Commit 185f54e

Browse files
Ignore file not found errors when loading org file that is not saved
1 parent d1d6eff commit 185f54e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lua/orgmode/parser/file.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,18 @@ function File.load(path, callback)
151151
return callback(nil)
152152
end
153153
local category = vim.fn.fnamemodify(path, ':t:r')
154-
utils.readfile(path):next(vim.schedule_wrap(function(content)
155-
return callback(File.from_content(content, category, path, ext == 'org_archive'))
156-
end))
154+
utils
155+
.readfile(path)
156+
:next(vim.schedule_wrap(function(content)
157+
return callback(File.from_content(content, category, path, ext == 'org_archive'))
158+
end))
159+
:catch(function(err)
160+
-- Ignore file not found errors
161+
if vim.startswith(err, 'ENOENT') then
162+
return
163+
end
164+
error(err)
165+
end)
157166
end
158167

159168
---@param content table

0 commit comments

Comments
 (0)