From 0814ba41ae899c2fbe5eac6cb37e9bccbcbe3d71 Mon Sep 17 00:00:00 2001 From: allhearingeye Date: Fri, 3 Oct 2025 19:25:41 +0400 Subject: [PATCH 1/2] fix(windows): handle Windows file paths correctly in refile There was a bug on Windows where the first character of the file name was dropped during refile. This happened because an extra leading / was added to the beginning of the path, resulting in something like: `/C:/org/file.org` which was then displayed as: `ile.org`. Some issue was reported in https://github.com/nvim-orgmode/orgmode/issues/911, but not fixed on Windows. --- lua/orgmode/utils/fs.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/orgmode/utils/fs.lua b/lua/orgmode/utils/fs.lua index d06c2883e..f10aca1e0 100644 --- a/lua/orgmode/utils/fs.lua +++ b/lua/orgmode/utils/fs.lua @@ -111,7 +111,12 @@ function M.trim_common_root(paths) end, paths) end - local root = '/' .. table.concat(common_root, '/') .. '/' + local root + if vim.fn.has('win32') == 1 then + root = table.concat(common_root, '/') .. '/' + else + root = '/' .. table.concat(common_root, '/') .. '/' + end local result = {} for _, path in ipairs(paths) do local relative_path = path:sub(#root + 1) From 2e619b68bc17beca77286b19e013bf7d1fcd2144 Mon Sep 17 00:00:00 2001 From: allhearingeye Date: Sat, 4 Oct 2025 04:42:13 +0400 Subject: [PATCH 2/2] apply reviewer suggestion for Windows path handling Co-authored-by: Kristijan Husak --- lua/orgmode/utils/fs.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/orgmode/utils/fs.lua b/lua/orgmode/utils/fs.lua index f10aca1e0..79dd586ab 100644 --- a/lua/orgmode/utils/fs.lua +++ b/lua/orgmode/utils/fs.lua @@ -111,11 +111,9 @@ function M.trim_common_root(paths) end, paths) end - local root - if vim.fn.has('win32') == 1 then - root = table.concat(common_root, '/') .. '/' - else - root = '/' .. table.concat(common_root, '/') .. '/' + local root = table.concat(common_root, '/') .. '/' + if vim.fn.has('win32') == 0 then + root = '/' .. root end local result = {} for _, path in ipairs(paths) do