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')
3
3
local Hyperlinks = {}
4
4
5
5
local 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 )
7
16
end
8
17
9
18
local function update_hyperlink_ctx (ctx )
@@ -23,6 +32,10 @@ local function update_hyperlink_ctx(ctx)
23
32
file_match = Hyperlinks .get_file_real_path (file_match )
24
33
end
25
34
35
+ if file_match then
36
+ file_match = vim .loop .fs_realpath (file_match )
37
+ end
38
+
26
39
if file_match and Files .get (file_match ) then
27
40
hyperlinks_ctx .filepath = Files .get (file_match ).filename
28
41
hyperlinks_ctx .headline = ctx .line :match (' file:.-::(%*.-)$' )
Original file line number Diff line number Diff line change @@ -218,12 +218,16 @@ describe('Autocompletion', function()
218
218
})
219
219
220
220
mock_line (api , string.format (' [[file:%s::*' , filename ))
221
+ local vim_loop = mock (vim .loop , true )
222
+ vim_loop .fs_realpath .returns (filename )
221
223
result = OrgmodeOmniCompletion (0 , ' *' )
222
224
assert .are .same ({
223
225
{ menu = ' [Org]' , word = ' *' .. headlines [1 ].title },
224
226
{ menu = ' [Org]' , word = ' *' .. headlines [2 ].title },
225
227
}, result )
226
228
229
+ mock .revert (vim_loop )
230
+
227
231
mock .revert (MockFiles )
228
232
229
233
mock .revert (api )
You can’t perform that action at this time.
0 commit comments