Skip to content

Commit 03777ca

Browse files
fix(windows): handle Windows file paths correctly in refile (#1042)
* 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 #911, but not fixed on Windows. * apply reviewer suggestion for Windows path handling Co-authored-by: Kristijan Husak <[email protected]> --------- Co-authored-by: Kristijan Husak <[email protected]>
1 parent 4775d1a commit 03777ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/orgmode/utils/fs.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ function M.trim_common_root(paths)
111111
end, paths)
112112
end
113113

114-
local root = '/' .. table.concat(common_root, '/') .. '/'
114+
local root = table.concat(common_root, '/') .. '/'
115+
if vim.fn.has('win32') == 0 then
116+
root = '/' .. root
117+
end
115118
local result = {}
116119
for _, path in ipairs(paths) do
117120
local relative_path = path:sub(#root + 1)

0 commit comments

Comments
 (0)