Skip to content

Commit a273800

Browse files
authored
fix: follow internal links flawlessly (#638)
Remove the need to save the file before following internal links to headlines in the same file. Co-authored-by: Sebastian Flügge <[email protected]>
1 parent 8040906 commit a273800

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/orgmode/org/mappings.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ function OrgMappings:open_at_point()
805805
return
806806
end
807807

808+
-- handle external links (non-org or without org-specific line target)
808809
local url = link.url.str
809810
if link.url:is_file_plain() then
810811
local file_path = link.url:get_filepath()
@@ -854,7 +855,12 @@ function OrgMappings:open_at_point()
854855
end
855856
headline = headlines[choice]
856857
end
857-
vim.cmd(string.format('edit %s', headline.file))
858+
859+
if link.url:is_file() then
860+
vim.cmd(string.format('edit %s', headline.file))
861+
else
862+
vim.cmd([[normal! m']]) -- add link source to jumplist
863+
end
858864
vim.fn.cursor({ headline.range.start_line, 0 })
859865
vim.cmd([[normal! zv]])
860866
end

0 commit comments

Comments
 (0)