Skip to content

fix(filesystem): follow files through symlinks #1731

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lua/neo-tree/sources/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ M.get_state_for_window = function(winid)
end
end

---Gets the path to reveal.
---@param include_terminals boolean?
---@return string? bufname_path The non-canonical path (keeps the symlinks in the path without resolving them)
---@return string? realpath The real path of the item to reveal
M.get_path_to_reveal = function(include_terminals)
local win_id = vim.api.nvim_get_current_win()
local cfg = vim.api.nvim_win_get_config(win_id)
Expand All @@ -149,14 +153,22 @@ M.get_path_to_reveal = function(include_terminals)
if vim.bo.filetype == "neo-tree" then
return nil
end
local path = vim.fn.expand("%:p")
if not utils.truthy(path) then

local realpath = vim.fn.expand("%:p")
if not utils.truthy(realpath) then
return nil
end
if not include_terminals and path:match("term://") then
if not include_terminals and realpath:match("term://") then
return nil
end
return path

local relative_bufname = vim.fn.fnamemodify(vim.fn.expand("%"), ":.")
local bufname_path = vim.fs.normalize(utils.path_join(vim.fn.getcwd(win_id), relative_bufname))
if utils.is_windows then
bufname_path = utils.windowize_path(bufname_path)
end

return bufname_path, realpath
end

M.subscribe = function(source_name, event)
Expand Down
Loading