@@ -27,16 +27,12 @@ local function save_bookmarks(marks, opts)
27
27
for path , _ in pairs (marks ) do
28
28
table.insert (data , path )
29
29
end
30
- print (storepath )
31
30
file :write (vim .json .encode (data ))
32
31
file :close ()
33
32
end
34
33
end
35
34
36
35
local function load_bookmarks (opts )
37
- if not opts .marks .enable_persistence then
38
- return {}
39
- end
40
36
local storepath = get_save_path (opts )
41
37
local file = io.open (storepath , " r" )
42
38
if file then
@@ -69,7 +65,15 @@ local Marks = Class:extend()
69
65
--- @param args MarksArgs
70
66
function Marks :new (args )
71
67
self .explorer = args .explorer
72
- self .marks = load_bookmarks (self .explorer .opts ) or {}
68
+ self .marks = {}
69
+ if self .explorer .opts .marks .enable_persistence then
70
+ local ok , loaded_marks = pcall (load_bookmarks , self .explorer .opts )
71
+ if ok then
72
+ self .marks = loaded_marks
73
+ else
74
+ notify .warn (" Failed to load bookmarks: " .. loaded_marks )
75
+ end
76
+ end
73
77
end
74
78
75
79
--- Clear all marks and reload if watchers disabled
@@ -100,7 +104,13 @@ function Marks:toggle(node)
100
104
else
101
105
self .marks [node .absolute_path ] = node
102
106
end
103
- save_bookmarks (self .marks , self .explorer .opts )
107
+
108
+ if self .explorer .opts .marks .enable_persistence then
109
+ local ok , err = pcall (save_bookmarks , self .marks , self .explorer .opts )
110
+ if not ok then
111
+ notify .warn (" Failed to save bookmarks: " .. err )
112
+ end
113
+ end
104
114
self .explorer .renderer :draw ()
105
115
end
106
116
0 commit comments