@@ -141,14 +141,20 @@ module.config.public = {
141
141
142
142
-- Timezone information in the timestamps
143
143
-- - "utc" the timestamp is in UTC+0
144
- -- - "local" the timestmap is in the local timezone
144
+ -- - "local" the timestamp is in the local timezone
145
145
-- - "implicit-local" like "local", but the timezone information is omitted from the timestamp
146
146
timezone = " local" ,
147
+
148
+ -- Whether or not to call :h :undojoin just before changing the timestamp in `update_metadata`
149
+ -- This will make your undo key undo the last change before writing the file in addition to the
150
+ -- timestamp change. This will move your cursor to the top of the file.
151
+ undojoin_updates = false ,
147
152
}
148
153
149
154
module .private = {
150
155
buffers = {},
151
156
listen_event = " none" ,
157
+ skip_next_update = false ,
152
158
}
153
159
154
160
--- @class core.esupports.metagen
@@ -203,6 +209,11 @@ module.public = {
203
209
}
204
210
end ,
205
211
212
+ --- Skip the next call to update_metadata
213
+ skip_next_update = function ()
214
+ module .private .skip_next_update = true
215
+ end ,
216
+
206
217
--- @class core.esupports.metagen.metadata
207
218
--- @field title ? function | string the title of the note
208
219
--- @field description ? function | string the description of the note
@@ -261,8 +272,12 @@ module.public = {
261
272
end ,
262
273
263
274
update_metadata = function (buf )
264
- local present = module .public .is_metadata_present (buf )
275
+ if module .private .skip_next_update then
276
+ module .private .skip_next_update = false
277
+ return
278
+ end
265
279
280
+ local present = module .public .is_metadata_present (buf )
266
281
if not present then
267
282
return
268
283
end
@@ -324,6 +339,9 @@ module.public = {
324
339
if date ~= current_date then
325
340
local range = module .required [" core.integrations.treesitter" ].get_node_range (node )
326
341
342
+ if module .config .public .undojoin_updates then
343
+ vim .cmd .undojoin ()
344
+ end
327
345
vim .api .nvim_buf_set_text (
328
346
buf ,
329
347
range .row_start ,
0 commit comments