Merge branch 'master' into 2746-float-window-for-full-filenames-has-wrong-bg
This commit is contained in:
commit
1872b04aad
@ -242,6 +242,9 @@ local function setup_autocommands(opts)
|
|||||||
pattern = "*",
|
pattern = "*",
|
||||||
---@param ev vim.api.keyset.create_autocmd.callback_args
|
---@param ev vim.api.keyset.create_autocmd.callback_args
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
|
if not vim.api.nvim_buf_is_valid(ev.buf) then
|
||||||
|
return
|
||||||
|
end
|
||||||
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
|
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
|
||||||
require("nvim-tree.events")._dispatch_on_tree_close()
|
require("nvim-tree.events")._dispatch_on_tree_close()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -135,7 +135,7 @@ end
|
|||||||
function Builder:format_line(indent_markers, arrows, icon, name, node)
|
function Builder:format_line(indent_markers, arrows, icon, name, node)
|
||||||
local added_len = 0
|
local added_len = 0
|
||||||
local function add_to_end(t1, t2)
|
local function add_to_end(t1, t2)
|
||||||
if not t2 then
|
if not t2 or vim.tbl_isempty(t2) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for _, v in ipairs(t2) do
|
for _, v in ipairs(t2) do
|
||||||
|
|||||||
@ -303,11 +303,51 @@ function M.rename_loaded_buffers(old_path, new_path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local is_windows_drive = function(path)
|
||||||
|
return (M.is_windows) and (path:match("^%a:\\$") ~= nil)
|
||||||
|
end
|
||||||
|
|
||||||
---@param path string path to file or directory
|
---@param path string path to file or directory
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function M.file_exists(path)
|
function M.file_exists(path)
|
||||||
local _, error = vim.loop.fs_stat(path)
|
if not (M.is_windows or M.is_wsl) then
|
||||||
return error == nil
|
local _, error = vim.loop.fs_stat(path)
|
||||||
|
return error == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Windows is case-insensetive, but case-preserving
|
||||||
|
-- If a file's name is being changed into itself
|
||||||
|
-- with different casing, windows will falsely
|
||||||
|
-- report that file is already existing, so a hand-rolled
|
||||||
|
-- implementation of checking for existance is needed.
|
||||||
|
-- Same holds for WSL, since it can sometimes
|
||||||
|
-- access Windows files directly.
|
||||||
|
-- For more details see (#3117).
|
||||||
|
|
||||||
|
if is_windows_drive(path) then
|
||||||
|
return vim.fn.isdirectory(path) == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local parent = vim.fn.fnamemodify(path, ":h")
|
||||||
|
local filename = vim.fn.fnamemodify(path, ":t")
|
||||||
|
|
||||||
|
local handle = vim.loop.fs_scandir(parent)
|
||||||
|
if not handle then
|
||||||
|
-- File can not exist if its parent directory does not exist
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local name, _ = vim.loop.fs_scandir_next(handle)
|
||||||
|
if not name then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if name == filename then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user