Skip to content

Commit 77b4cc8

Browse files
Übertreiberbroken-pen
andauthored
fix: missing nil check in open_at_point() (#546)
Without the check, attempting to open a link like [[file:./file.org::*Heading]] outside of any heading would cause a Lua error. Co-authored-by: Nico Madysa <[email protected]>
1 parent 2cb04d7 commit 77b4cc8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/orgmode/org/mappings.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,13 @@ function OrgMappings:open_at_point()
783783
return vim.cmd(string.format('edit %s', url))
784784
end
785785

786+
local headlines = Hyperlinks.find_matching_links(link_ctx)
786787
local current_headline = Files.get_closest_headline()
787-
local headlines = vim.tbl_filter(function(headline)
788-
return headline.line ~= current_headline.line and headline.id ~= current_headline.id
789-
end, Hyperlinks.find_matching_links(link_ctx))
788+
if current_headline then
789+
headlines = vim.tbl_filter(function(headline)
790+
return headline.line ~= current_headline.line and headline.id ~= current_headline.id
791+
end, headlines)
792+
end
790793
if #headlines == 0 then
791794
return
792795
end

0 commit comments

Comments
 (0)