-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix joining paths in Windows (#168)
* fix: use plenary.path to manage paths in Windows * fix: filter out paths validly in Windows * fix: detect default `ignore_patterns` in Windows fix: #169 * fix: join paths validly in Windows * docs: fix value for `ignore_patterns` in Windows * fix: avoid duplication of separators in paths Fix: #171 This fixes only in native logic. The one with SQLite has still bugs. ……but that may not be fixed.
- Loading branch information
Showing
7 changed files
with
62 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
local Path = require "plenary.path" | ||
local uv = vim.uv or vim.loop | ||
|
||
local M = { | ||
is_windows = uv.os_uname().sysname == "Windows_NT", | ||
} | ||
|
||
---@type fun(filename: string): string | ||
M.normalize_sep = M.is_windows | ||
and function(filename) | ||
if not filename:find("/", 1, true) or filename:match "^%a+://" then | ||
return filename | ||
end | ||
local replaced = filename:gsub("/", Path.path.sep) | ||
return replaced | ||
end | ||
or function(filename) | ||
return filename | ||
end | ||
|
||
--- Join path segments into a single path string. | ||
--- NOTE: Do not use vim.fs.joinpath because it does not work on Windows. | ||
---@type fun(...: string): string | ||
M.join_path = M.is_windows and function(...) | ||
return M.normalize_sep(Path:new(...).filename) | ||
end or function(...) | ||
return Path:new(...).filename | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters