Closed rick-yao closed 9 months ago
experiencing the same thing
update: downgrading to 3.14 has fixed the issue for me:
use({ "nvim-neo-tree/neo-tree.nvim", tag = "3.14" })
Hi, I'm gonna take a look into this. Probably related to the changes I made.
Hello, I tried and couldn't reproduce it with neovim 0.9.5 and with neo-tree's repro.lua (as stated in the bug report template):
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
-- add any other plugins here
}
local neotree_config = {
"nvim-neo-tree/neo-tree.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
cmd = { "Neotree" },
keys = {
{ "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
},
opts = {
log_level = "trace",
log_to_file = "/tmp/neotree-repro.log",
filesystem = {
filtered_items = {
visible = true,
show_hidden_count = true,
hide_dotfiles = false,
hide_gitignored = true,
hide_by_name = {
-- '.git',
-- '.DS_Store',
-- 'thumbs.db',
},
never_show = {},
},
},
window = {
position = "right",
},
},
}
table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
I included your config as well.
It seems that AstroNvim overwrites some commands from neo-tree here. I'd suggest opening an issue there.
Thanks for your quick reply ,I'll open an issue at Astronvim.
the issue is gone when i fallback to 3.14, issue closed. Both neo-tree and astronvim cannot replicate it. issue closed.
@georgeguimaraes it does have to do with this commit you made (found with git bisect
): https://github.com/nvim-neo-tree/neo-tree.nvim/pull/1288
It seems to cause this bug in the custom hjkl based navigation described in this discussion: https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/163
I'm not sure if this is considered a bug/issue in neo-tree. If not, I can just remove this custom code from AstroNvim since there is no place for unstable code in there.
Thanks in advanced if you take a look at this! No worries if you don't have time!
You might have a better idea than me @georgeguimaraes if the PR introduced a bug or if the code in the linked comment (https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/163#discussioncomment-4747082) has just always had a bug in it and this just exposed it. The code there seems relatively straightforward and that it should work, but I don't have a full understanding of the neo-tree internals like yourself. So it would be difficult for me to identify which side of the equation the bug would be considered
Looking at the video, it does not seem random at all. From what I can see, it is jumping to the currently active file in the buffer to the left.
More importantly, when I use the provided config and just add the custom h
/l
mappings, i don't see the same behavior:
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
-- add any other plugins here
}
local neotree_config = {
"nvim-neo-tree/neo-tree.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
cmd = { "Neotree" },
keys = {
{ "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
},
opts = {
log_level = "trace",
log_to_file = "/tmp/neotree-repro.log",
filesystem = {
filtered_items = {
visible = true,
show_hidden_count = true,
hide_dotfiles = false,
hide_gitignored = true,
hide_by_name = {
-- '.git',
-- '.DS_Store',
-- 'thumbs.db',
},
never_show = {},
},
window = {
mappings = {
h = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_parent_id())
end
end,
l = function(state)
local node = state.tree:get_node()
if node.type == "directory" or node:has_children() then
if not node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
end
end
end,
},
}
},
window = {
position = "right",
},
},
}
table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
I am using nvim version 0.9.4 on linux.
@cseickel it actually doesn't happen 100% of the time. It took me a while to replicate it. Also it doesn't always jump to the currently active file. Sometimes it will jump to a different directory I have recently toggled. I will see if I can get a specific set of actions to replicate it, but so far I have struggled to consistently replicate it without just sitting and doing a lot of actions in the file tree until it happens
I've managed to replicate it with a minimal config (with hl keys). It does not happen all the time, but it does trigger an out of order renderer.position.save that I still don't know why.
Investigating.
Thanks so much for taking some time to investigate this @georgeguimaraes !
@mehalter I've proposed a fix. It's hard for me to debug it, because the issue doesn't happen a lot here. If you could try it, it would help a lot:
sorry to make this issue is resurrect. i'm still experience with the issue. i was reinstalling the plugin but it's still occour. if you don't mind let me add some information here. i hope is helpfull. thanks
NVIM v0.10.0-dev-2501+gdbf6be296 Build type: RelWithDebInfo LuaJIT 2.1.1707061634
arch linux
v3.17
open folder with l
or enter
key, make cursor random jump, it will jump some line above or below from old cursor position(before open folder) . but it's randomly happen, i think it's happen when i moving fast in neo-tree but i'm not sure with this.
@rizkyilhampra Could you join the discussion here? https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1374
It might be caused by an upstream issue in neovim and maybe not...
Do you remember when you installed that neovim? If it's newer than November, it might be neo-tree's position restore mechanism conflicting with https://github.com/neovim/neovim/issues/27720.
Sorry, wrong link. Updated.
@pysan3 yes my neovim version is newer than november, to be exact the last i'm updated i think is yesterday.
thanks for give me some related information, i will check it out and following the related infomation.
Did you check docs and existing issues?
Neovim Version (nvim -v)
NVIM v0.9.5 Build type: Release LuaJIT 2.1.1693350652
Operating System / Version
macos 14.2.1
Describe the Bug
some times when opening folder, cursor will jump to a random item rather than stay at the foler. some times it jump to opened file ,sometimes it jump to item in the folder. i couldn't get exact clue.
Screenshots, Traceback
replicate video
Steps to Reproduce
Expected Behavior
the cursor should stay at the folder item.
Your Configuration