@@ -3,9 +3,9 @@ local OrgApi = require('orgmode.api')
3
3
local M = {}
4
4
5
5
function M .load_files (opts )
6
- --- @type { filename : string , last_used : number , title : string } []
6
+ --- @type { filename : string , title : string } []
7
7
local file_results = vim .tbl_map (function (file )
8
- return { filename = file .filename , last_used = file . metadata . mtime , title = file :get_title () }
8
+ return { filename = file .filename , title = file :get_title () }
9
9
end , require (' orgmode' ).files :all ())
10
10
11
11
if not opts .archived then
@@ -15,16 +15,17 @@ function M.load_files(opts)
15
15
end
16
16
17
17
table.sort (file_results , function (a , b )
18
- return a .last_used > b .last_used
18
+ local stat_a = vim .uv .fs_stat (a .filename )
19
+ local stat_b = vim .uv .fs_stat (b .filename )
20
+ local mtime_a = stat_a and stat_a .mtime .sec or 0
21
+ local mtime_b = stat_b and stat_b .mtime .sec or 0
22
+ return mtime_a > mtime_b
19
23
end )
20
24
21
25
return file_results
22
26
end
23
27
24
28
function M .load_headlines (opts )
25
- --- @type { filename : string , title : string , level : number , line_number : number , all_tags : string[] , is_archived : boolean } []
26
- local results = {}
27
-
28
29
-- Get files sorted by modification time (most recent first)
29
30
local files = require (' orgmode' ).files :all ()
30
31
if not opts .archived then
@@ -34,9 +35,15 @@ function M.load_headlines(opts)
34
35
end
35
36
36
37
table.sort (files , function (a , b )
37
- return a .metadata .mtime < b .metadata .mtime
38
+ local stat_a = vim .uv .fs_stat (a .filename )
39
+ local stat_b = vim .uv .fs_stat (b .filename )
40
+ local mtime_a = stat_a and stat_a .mtime .sec or 0
41
+ local mtime_b = stat_b and stat_b .mtime .sec or 0
42
+ return mtime_a > mtime_b
38
43
end )
39
44
45
+ --- @type { filename : string , title : string , level : number , line_number : number , all_tags : string[] , is_archived : boolean } []
46
+ local results = {}
40
47
for _ , file in ipairs (files ) do
41
48
-- Skip archive files unless explicitly requested
42
49
local headlines = opts .archived and file :get_headlines_including_archived () or file :get_headlines ()
0 commit comments