File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,14 @@ function M.insert(_)
6060 --- @type MatchEntry
6161 local entry = action_state .get_selected_entry ()
6262
63- -- Link to the filename by default
64- local destination = entry .value .file .filename
65-
66- -- Link to a specific heading if is set
67- if entry .value .headline then
68- destination = org .get_link_to_headline (entry .value .headline )
69- end
63+ local destination = (function ()
64+ if entry .value .headline then
65+ -- Link to a specific heading if is set
66+ return org .get_link_to_headline (entry .value .headline )
67+ else
68+ return org .get_link_to_file (entry .value .file )
69+ end
70+ end )()
7071
7172 org .insert_link (destination )
7273 return true
Original file line number Diff line number Diff line change 1- local config = require (' telescope-orgmode.config' )
21local to_actions = require (' telescope-orgmode.actions' )
32
43local M = {}
Original file line number Diff line number Diff line change 3131--- @param headline OrgApiHeadline
3232--- @return string
3333function M .get_link_to_headline (headline )
34- return OrgApi .get_link_to_headline (headline ._section ) --- @diagnostic disable-line : invisible
34+ return OrgApi .get_link_to_headline (headline )
35+ end
36+
37+ --- @param file OrgApiFile
38+ --- @return string
39+ function M .get_link_to_file (file )
40+ return OrgApi .get_link_to_file (file )
3541end
3642
3743function M .insert_link (destination )
You can’t perform that action at this time.
0 commit comments