Revert "fix(#1815): don't schedule find_file calls, debounce update_focused_file with 15ms default (#1820)"
This reverts commit 623cecb809.
This commit is contained in:
parent
623cecb809
commit
a8d26bb088
@ -280,7 +280,6 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
},
|
},
|
||||||
update_focused_file = {
|
update_focused_file = {
|
||||||
enable = false,
|
enable = false,
|
||||||
debounce_delay = 15,
|
|
||||||
update_root = false,
|
update_root = false,
|
||||||
ignore_list = {},
|
ignore_list = {},
|
||||||
},
|
},
|
||||||
@ -508,11 +507,6 @@ until it finds the file.
|
|||||||
Enable this feature.
|
Enable this feature.
|
||||||
Type: `boolean`, Default: `false`
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
*nvim-tree.update_focused_file.debounce_delay*
|
|
||||||
Idle milliseconds between BufEnter and update.
|
|
||||||
The last BufEnter will be focused, others are discarded.
|
|
||||||
Type: `number`, Default: `15` (ms)
|
|
||||||
|
|
||||||
*nvim-tree.update_focused_file.update_root* (previously `update_focused_file.update_cwd`)
|
*nvim-tree.update_focused_file.update_root* (previously `update_focused_file.update_cwd`)
|
||||||
Update the root directory of the tree if the file is not under current
|
Update the root directory of the tree if the file is not under current
|
||||||
root directory. It prefers vim's cwd and `root_dirs`.
|
root directory. It prefers vim's cwd and `root_dirs`.
|
||||||
|
|||||||
@ -76,7 +76,7 @@ function M.toggle(find_file, no_focus, cwd, bang)
|
|||||||
local previous_buf = vim.api.nvim_get_current_buf()
|
local previous_buf = vim.api.nvim_get_current_buf()
|
||||||
M.open(cwd)
|
M.open(cwd)
|
||||||
if _config.update_focused_file.enable or find_file then
|
if _config.update_focused_file.enable or find_file then
|
||||||
find_file(false, previous_buf, bang)
|
M.find_file(false, previous_buf, bang)
|
||||||
end
|
end
|
||||||
if no_focus then
|
if no_focus then
|
||||||
vim.cmd "noautocmd wincmd p"
|
vim.cmd "noautocmd wincmd p"
|
||||||
@ -143,7 +143,7 @@ local function is_file_readable(fname)
|
|||||||
return stat and stat.type == "file" and vim.loop.fs_access(fname, "R")
|
return stat and stat.type == "file" and vim.loop.fs_access(fname, "R")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function find_file(with_open, bufnr, bang)
|
function M.find_file(with_open, bufnr, bang)
|
||||||
if not with_open and not core.get_explorer() then
|
if not with_open and not core.get_explorer() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -162,20 +162,13 @@ local function find_file(with_open, bufnr, bang)
|
|||||||
M.open()
|
M.open()
|
||||||
end
|
end
|
||||||
|
|
||||||
if bang or _config.update_focused_file.update_root then
|
-- if we don't schedule, it will search for NvimTree
|
||||||
M.change_root(filepath, bufnr)
|
vim.schedule(function()
|
||||||
end
|
if bang or _config.update_focused_file.update_root then
|
||||||
|
M.change_root(filepath, bufnr)
|
||||||
require("nvim-tree.actions.finders.find-file").fn(filepath)
|
end
|
||||||
end
|
require("nvim-tree.actions.finders.find-file").fn(filepath)
|
||||||
|
end)
|
||||||
---@deprecated 2022/12/16
|
|
||||||
function M.find_file(with_open, bufnr, bang)
|
|
||||||
vim.notify_once(
|
|
||||||
"require('nvim-tree').find_file is not API and will soon be unavailable. Please use api.tree.find_file as per :help nvim-tree-api",
|
|
||||||
vim.log.levels.WARN
|
|
||||||
)
|
|
||||||
find_file(with_open, bufnr, bang)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
M.resize = view.resize
|
M.resize = view.resize
|
||||||
@ -279,7 +272,7 @@ function M.on_enter(netrw_disabled)
|
|||||||
if should_focus_other_window then
|
if should_focus_other_window then
|
||||||
vim.cmd "noautocmd wincmd p"
|
vim.cmd "noautocmd wincmd p"
|
||||||
if should_find then
|
if should_find then
|
||||||
find_file(false)
|
M.find_file(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -313,7 +306,7 @@ local function setup_vim_commands()
|
|||||||
vim.api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, { bar = true })
|
vim.api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, { bar = true })
|
||||||
vim.api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, { bar = true })
|
vim.api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, { bar = true })
|
||||||
vim.api.nvim_create_user_command("NvimTreeFindFile", function(res)
|
vim.api.nvim_create_user_command("NvimTreeFindFile", function(res)
|
||||||
find_file(true, nil, res.bang)
|
M.find_file(true, nil, res.bang)
|
||||||
end, { bang = true, bar = true })
|
end, { bang = true, bar = true })
|
||||||
vim.api.nvim_create_user_command("NvimTreeFindFileToggle", function(res)
|
vim.api.nvim_create_user_command("NvimTreeFindFileToggle", function(res)
|
||||||
M.toggle(true, false, res.args, res.bang)
|
M.toggle(true, false, res.args, res.bang)
|
||||||
@ -331,7 +324,7 @@ function M.change_dir(name)
|
|||||||
change_dir.fn(name)
|
change_dir.fn(name)
|
||||||
|
|
||||||
if _config.update_focused_file.enable then
|
if _config.update_focused_file.enable then
|
||||||
find_file(false)
|
M.find_file(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -407,9 +400,7 @@ local function setup_autocommands(opts)
|
|||||||
if opts.update_focused_file.enable then
|
if opts.update_focused_file.enable then
|
||||||
create_nvim_tree_autocmd("BufEnter", {
|
create_nvim_tree_autocmd("BufEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
utils.debounce("BufEnter:find_file", opts.update_focused_file.debounce_delay, function()
|
M.find_file(false)
|
||||||
find_file(false)
|
|
||||||
end)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -581,7 +572,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
},
|
},
|
||||||
update_focused_file = {
|
update_focused_file = {
|
||||||
enable = false,
|
enable = false,
|
||||||
debounce_delay = 15,
|
|
||||||
update_root = false,
|
update_root = false,
|
||||||
ignore_list = {},
|
ignore_list = {},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user