File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,16 @@ local utils = require('orgmode.utils')
33local Hyperlinks = {}
44
55local function get_file_from_context (ctx )
6- return (ctx .hyperlinks and ctx .hyperlinks .filepath and Files .get (ctx .hyperlinks .filepath ) or Files .get_current_file ())
6+ local filepath = (ctx .hyperlinks and ctx .hyperlinks .filepath )
7+ if not filepath then
8+ return Files .get_current_file ()
9+ end
10+ local canonical = vim .loop .fs_realpath (filepath )
11+ if not canonical then
12+ return Files .get_current_file ()
13+ end
14+
15+ return Files .get (canonical )
716end
817
918local function update_hyperlink_ctx (ctx )
@@ -23,6 +32,10 @@ local function update_hyperlink_ctx(ctx)
2332 file_match = Hyperlinks .get_file_real_path (file_match )
2433 end
2534
35+ if file_match then
36+ file_match = vim .loop .fs_realpath (file_match )
37+ end
38+
2639 if file_match and Files .get (file_match ) then
2740 hyperlinks_ctx .filepath = Files .get (file_match ).filename
2841 hyperlinks_ctx .headline = ctx .line :match (' file:.-::(%*.-)$' )
Original file line number Diff line number Diff line change @@ -218,12 +218,16 @@ describe('Autocompletion', function()
218218 })
219219
220220 mock_line (api , string.format (' [[file:%s::*' , filename ))
221+ local vim_loop = mock (vim .loop , true )
222+ vim_loop .fs_realpath .returns (filename )
221223 result = OrgmodeOmniCompletion (0 , ' *' )
222224 assert .are .same ({
223225 { menu = ' [Org]' , word = ' *' .. headlines [1 ].title },
224226 { menu = ' [Org]' , word = ' *' .. headlines [2 ].title },
225227 }, result )
226228
229+ mock .revert (vim_loop )
230+
227231 mock .revert (MockFiles )
228232
229233 mock .revert (api )
You can’t perform that action at this time.
0 commit comments