Skip to content

Commit

Permalink
fix(hyperlink): Fix jumping to file
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Sep 16, 2024
1 parent 5e567b1 commit ade2275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/orgmode/org/links/types/headline_search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function OrgLinkHeadlineSearch:follow(link)
local file = self.files:load_file_sync(opts.file_path)

if file then
if opts.type == 'file' and not opts.target then
return link_utils.goto_file(file)
end

local pattern = ('<<<?(%s[^>]*)>>>?'):format(opts.headline_text):lower()
local headlines = file:find_headlines_matching_search_term(pattern, true)
if #headlines == 0 then
Expand Down
2 changes: 1 addition & 1 deletion tests/plenary/ui/mappings/hyperlink_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ describe('Hyperlink mappings', function()

it('should store link to a headline with id', function()
---@diagnostic disable-next-line: invisible
require('orgmode').links.stored_links = {}
local org = require('orgmode').setup({
org_id_link_to_org_use_id = true,
})
require('orgmode').links.stored_links = {}
helpers.create_file({
'* Test hyperlink',
' - some',
Expand Down

0 comments on commit ade2275

Please sign in to comment.