Skip to content

Commit 828c4b5

Browse files
author
troiganto
committed
fix(attach): unset_directory couldn't switch from DIR to ID directory
1 parent c8812de commit 828c4b5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/orgmode/attach/core.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,13 @@ end
308308
function AttachCore:unset_directory(node, opts)
309309
local old_dir = self:get_dir(node, true)
310310
node:set_dir()
311-
local new_dir = self:get_dir(node, true) -- new dir potentially via parent nodes
311+
-- After removal, there might be a new DIR directory via inheritance.
312+
local new_dir = self:get_dir_or_nil(node, true)
313+
if not new_dir then
314+
-- There is no parent node with a DIR property. Switch back to ID-based
315+
-- directory.
316+
new_dir = node:id_dir_get_or_create()
317+
end
312318
-- Ordering matters here: both `opts` should be evaluated before the
313319
-- operations (copy if desired, delete if desired) start.
314320
---@param do_copy? boolean

0 commit comments

Comments
 (0)