Skip to content

Commit 23526f9

Browse files
Do not throw error if current text is on top level.
1 parent 35504ab commit 23526f9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lua/orgmode/parser/file.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ function File:_parse()
4747
end
4848

4949
function File:get_errors()
50-
local has_error = self.tree:root():has_error()
51-
if not has_error then
50+
if not self:has_errors() then
5251
return nil
5352
end
5453

5554
return self:get_ts_matches('(ERROR) @err')
5655
end
5756

57+
---@return boolean
58+
function File:has_errors()
59+
return self.tree:root():has_error()
60+
end
61+
5862
function File:convert_to_file_node(node)
5963
local text = self:get_node_text(node)
6064
local stars = text:match('^%*+')

lua/orgmode/parser/files.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function Files.get_closest_headline(id)
215215
error({ message = string.format('Failed to parse current file. %s.', msg) })
216216
end
217217
local headline = current_file:get_closest_headline(id)
218-
if not headline then
218+
if not headline and current_file:has_errors() then
219219
error({ message = string.format('Failed to parse current headline. %s.', msg) })
220220
end
221221
return headline

0 commit comments

Comments
 (0)