Skip to content

Commit

Permalink
fix: use backslashes for Windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed Jan 22, 2024
1 parent 1189184 commit b5d7492
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lua/frecency/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ FS.new = function(config)
return "^" .. regex .. "$"
end, self.config.ignore_patterns)
---This is needed for Neovim v0.9.0.
self.joinpath = vim.fs.joinpath or function(...)
return (table.concat({ ... }, "/"):gsub("//+", "/"))
self.joinpath = function(...)
return Path:new(...).filename
end
return self
end
Expand All @@ -56,9 +56,10 @@ function FS:scan_dir(path)
end,
})
do
local fullpath = self.joinpath(path, name)
local escaped = Path.path.sep ~= "/" and name:gsub("/", Path.path.sep) or name
local fullpath = self.joinpath(path, escaped)
if type == "file" and not self:is_ignored(fullpath) and gitignore({ path }, fullpath) then
coroutine.yield(name)
coroutine.yield(escaped)
end
end
end)
Expand Down
5 changes: 3 additions & 2 deletions lua/frecency/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ end
---@return string
function Picker:default_path_display(opts, path)
local filename = Path:new(path):make_relative(opts.cwd)
log.debug { cwd = opts.cwd, before = path, after = filename }
if not self.workspace then
if vim.startswith(filename, self.fs.os_homedir) then
filename = "~/" .. self.fs:relative_from_home(filename)
filename = "~" .. Path.path.sep .. self.fs:relative_from_home(filename)
elseif filename ~= path then
filename = "./" .. filename
filename = "." .. Path.path.sep .. filename
end
end
return filename
Expand Down

0 comments on commit b5d7492

Please sign in to comment.