Skip to content

Commit 5659f78

Browse files
committed
fix: hijack_cursor with update_focused_file
1 parent 96a783f commit 5659f78

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lua/nvim-tree.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ function M.reset_highlight()
112112
renderer.render_hl(view.get_bufnr())
113113
end
114114

115-
local prev_line
116115
function M.place_cursor_on_node()
117-
local l = vim.api.nvim_win_get_cursor(0)[1]
118-
if l == prev_line then
116+
local search = vim.fn.searchcount()
117+
if search and search.exact_match == 1 then
119118
return
120119
end
121-
prev_line = l
122120

123121
local node = lib.get_node_at_cursor()
124122
if not node or node.name == ".." then
@@ -233,7 +231,7 @@ local function setup_autocommands(opts)
233231
create_nvim_tree_autocmd("TabEnter", { callback = vim.schedule_wrap(M.tab_enter) })
234232
end
235233
if opts.hijack_cursor then
236-
create_nvim_tree_autocmd("CursorMoved", {
234+
create_nvim_tree_autocmd({ "CursorMoved", "BufEnter" }, {
237235
pattern = "NvimTree_*",
238236
callback = function()
239237
if utils.is_nvim_tree_buf(0) then

0 commit comments

Comments
 (0)