diff options
author | Steven Arcangeli <stevearc@stevearc.com> | 2024-05-13 07:44:09 -0600 |
---|---|---|
committer | Steven Arcangeli <stevearc@stevearc.com> | 2024-05-13 07:44:38 -0600 |
commit | 4f0cdf07b5498935c34d6cfefde059a3a91584c4 (patch) | |
tree | c2eb24cf584ce0bfa947eafd80ce94a5433f458e | |
parent | dc950e5717f1da65b1fcd986b1bbff0d6bd0e2ee (diff) |
fix(windows): assertion failure when computing relative path (#400)
-rw-r--r-- | lua/conform/fs.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lua/conform/fs.lua b/lua/conform/fs.lua index 6f92e18..187bd7c 100644 --- a/lua/conform/fs.lua +++ b/lua/conform/fs.lua @@ -73,7 +73,15 @@ M.relative_path = function(source, target) while not M.is_subpath(source, target) do table.insert(path, "..") local new_source = vim.fs.dirname(source) - assert(source ~= new_source) + + -- If source is a root directory, we can't go up further so there is no relative path to the + -- target. This should only happen on Windows, which prohibits relative paths between drives. + if source == new_source then + local log = require("conform.log") + log.warn("Could not find relative path from %s to %s", source, target) + return target + end + source = new_source end |