nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.17k stars 609 forks source link

Open folder #1288

Closed azchatlanin closed 2 years ago

azchatlanin commented 2 years ago

Description

If you select a file from the previous folder, then close the folder, and then open another file in the new folder, then the old folder opens

Neovim version

last

Operating system and version

archlinux

nvim-tree version

master

Minimal config

local ok, nvim_tree = pcall(require, "nvim-tree")
if not ok then
  return
end

local config_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
if not config_ok then
  return
end

local tree_cb = nvim_tree_config.nvim_tree_callback

nvim_tree.setup {
  -- update_to_buf_dir = {
  --   enable = true,
  --   auto_open = true,
  -- },
  open_on_setup = false,
  filters = {
    dotfiles = false,
    custom = {},
  },
  disable_netrw = true,
  hijack_unnamed_buffer_when_opening = false,
  hijack_netrw = true,
  ignore_ft_on_setup = {
    "startify",
    "dashboard",
    "alpha",
  },
  open_on_tab = false,
  hijack_cursor = false,
  update_cwd = true,
  update_focused_file = {
    enable = true,
    update_cwd = false,
    ignore_list = {},
  },
  diagnostics = {
    enable = true,
    icons = {
      hint = "",
      info = "",
      warning = "",
      error = "",
    },
  },
  system_open = {
    cmd = nil,
    args = {},
  },
  git = {
    enable = true,
    ignore = true,
    timeout = 500,
  },
  view = {
    width = 40,
    height = 30,
    hide_root_folder = false,
    side = "left",
    mappings = {
      custom_only = false,
      list = {
        { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
        { key = "h", cb = tree_cb "close_node" },
        { key = "v", cb = tree_cb "vsplit" },
      },
    },
    number = false,
    relativenumber = false,
  },
  trash = {
    cmd = "trash",
    require_confirm = true,
  },
  -- disable_window_picker = 0,
  -- git_hl = 1,
  -- root_folder_modifier = ":t",
  -- show_icons = {
  --   git = 1,
  --   folders = 1,
  --   files = 1,
  --   folder_arrows = 1,
  --   tree_width = 30,
  -- },
}

Steps to reproduce

open the folder select any file in it to view close the folder go to another open folder select the file and see the self-opening old folder

bug_tree

Expected behavior

No response

Actual behavior

No response

kyazdani42 commented 2 years ago

I've noticed this too, but i haven't been able to reproduce consistently. Thanks for reporting this, i'll fix it asap.

azchatlanin commented 2 years ago

I saw that it was fixed, but I'm probably doing something wrong because I'm still observing the error.

I removed the plugin completely, reinstalled it again and the error is reproduced.

kyazdani42 commented 2 years ago

by doing exactly the pattern you mentionned in the issue ?

azchatlanin commented 2 years ago

Yes, it is. Open a folder Open File Close Folder Go to another folder Open File

result - the old folder opens

kyazdani42 commented 2 years ago

I cannot reproduce anymore, are you sure you are on the latest commit ?

azchatlanin commented 2 years ago

She appears again and again. Pleace, help me! What am I doing wrong?:)

NVIM v0.7.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by builduser

https://user-images.githubusercontent.com/21025345/170722646-571a1c7a-8353-464d-a829-c58e8d16ede5.mp4

azchatlanin commented 2 years ago

Today's update!

Screenshot_2022-05-28_08-16-08

alex-courtis commented 2 years ago

Today's update!

Is the problem resolved?

azchatlanin commented 2 years ago

Today's update!

Is the problem resolved?

No! I showed it that I have the latest version

azchatlanin commented 2 years ago

I am observing this error on three different machines. One of which is the server. It's strange, but I couldn't find any tests in your code. Apparently I was looking for it badly, probably.

alex-courtis commented 2 years ago

I couldn't find any tests in your code. Apparently I was looking for it badly, probably.

Sorry, no tests at the moment.

We will keep digging into this issue.

azchatlanin commented 2 years ago

Please tell me are you able to reproduce this error yourself? Or is it happening to me alone?

I tried to find the reason, but my knowledge of lua is not very good. But what I found out may help. Apparently, this is happening because of the render. For some reason, it continues to render closed directories as open.

alex-courtis commented 2 years ago

I'm not able to reproduce.

It looks like you might have some other plugins / automation running there. Can you reproduce this with nvt-min.lua as per bug report?

I tried to find the reason, but my knowledge of lua is not very good.

Logging can be helpful when you are trying to diagnose issues.

You can set all = true and add log lines e.g.:

    log.line("all", " bufpath '%s' severity %d", bufpath, severity)

Tail the log in another terminal while you're running your tests.

azchatlanin commented 2 years ago

Thank you so much for your patience. I found why this is happening. If you set this setting, you will see this effect.

opt.autochdir = true

alex-courtis commented 2 years ago

Thank you so much for your patience. I found why this is happening. If you set this setting, you will see this effect.

opt.autochdir = true

TIL