Open alex-courtis opened 2 months ago
I have been using this feature here for a while without any issues, but my usage scenario is relatively simple.
As long as the absolute path of the file is converted to a relative path before specifying the: edit (etc.) command, it should theoretically be sufficiently secure. Based on this, I rechecked the code and found that there is an area that needs to be fixed.
In local function open_in_new_window(filename, mode)
function, there is a problem with window jumping after converting to a relative path.
if (mode == "preview" or mode == "preview_no_picker") and view.View.float.enable then
-- ignore "WinLeave" autocmd on preview
-- because the registered "WinLeave"
-- will kill the floating window immediately
set_current_win_no_autocmd(target_winid, { "WinLeave", "BufEnter" })
else
set_current_win_no_autocmd(target_winid, { "BufEnter" })
end
pcall(vim.api.nvim_cmd, command, { output = false })
lib.set_target_win()
Can perform simple steps to reproduce this problem:
:NvimTreeOpen
" jump to a window to open file
:lcd ..
" jump to NvimTree window and select a file to open
This will open an incorrect path.
I just make a PR to fix it.
Thanks @epheien
I did expect several issues like these. We will fix them.
I was looking for this. Thanks.
I'll be using from now on and report if I find any issue.
This is looking good... over a month and no issues.
Are you happy to finish the experiment and make this the one and only way to open files @epheien ?
Experimental Features
nvim-tree has experimental features, previews of new functionality that will become default or optional functionality.
Please try these out and reply with your experiences. If you encounter a problem, please raise a bug report and indicate the experimental feature you are using.
2127 Open Buffers With Relative Path (#2805)
Buffers opened by nvim-tree will use with relative paths instead of absolute. Execute
:ls
to see the paths of all open buffers.:help nvim-tree.experimental.actions.open_file.relative_path
Enable:
2024 07 07 introduced, false by default