Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight_opened_files looks like doesn't work in explorer/init.lua #3101

Open
KH9IZ opened this issue Apr 6, 2025 · 5 comments · May be fixed by #3102
Open

highlight_opened_files looks like doesn't work in explorer/init.lua #3101

KH9IZ opened this issue Apr 6, 2025 · 5 comments · May be fixed by #3102
Labels
bug Something isn't working reproduced Issue confirmed

Comments

@KH9IZ
Copy link

KH9IZ commented Apr 6, 2025

Description

Found strange high level option highlight_opened_files used in explorer/init.lua

if (self.filters.state.no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then

if (self.filters.state.no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then

Is it forgotten self.renderer.highlight_opened_files or some hidden option?

For this reason can't force tree-nvim not to reload explorer for each opened file

Neovim version

NVIM v0.10.4
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Operating system and version

Linux 6.8.0-52-generic, 22.04.1-Ubuntu

Windows variant

No response

nvim-tree version

c09ff35

Clean room replication

My config:

    opts = {
      log = {
        enable = true,
        types = {
          all = true,
          -- config = true,
          -- copy_paste = true,
          -- dev = true,
          -- diagnostics = true,
          -- git = true,
          -- profile = false,
          -- watcher = true,
        },
      },
      filters = {enable=false,},
      view = {
        debounce_delay = 50,
        width = {
          max = 45
        },
        float = {
          enable = true,
          open_win_config = {
            relative = "win",
            height = 30,
            row = 0,
          }
        },
      },
      renderer = {
        full_name = true,
        group_empty = true,
        highlight_opened_files = "none",
      },
      git = {
        enable = false, 
        -- disable_for_dirs = {"/home/egorknyazev/"},
      },
      filesystem_watchers = {
        enable = false,
        -- ignore_dirs
      },
      reload_on_bufenter = false,
      auto_reload_on_write = false,
      sync_root_with_cwd = false,
      hijack_cursor = false,
      auto_reload_on_write = false,
    },

Steps to reproduce

  1. Set highlight_opened_files = "none",
  2. Enable logging
  3. Check log

Expected behavior

No reload on open new buffer

Actual behavior

Reload on each open and close buffer

@KH9IZ KH9IZ added the bug Something isn't working label Apr 6, 2025
@alex-courtis
Copy link
Member

Good catch, that looks like an error intruduced during a refactor. It should be self.opts.renderer.highlight_opened_files
That will be fixed.

Why do we reload on this event?
I seem to recall a reason when this was implemented, I'll dig. Perhaps some nvim limitation that no longer exists?
It may be replaceable with a self.renderer:draw()

@alex-courtis
Copy link
Member

It looks like the BufUnload event used to track the unloaded bufnr however that appears to be no longer necessary: fb2e4f1

@alex-courtis
Copy link
Member

It looks like a draw is sufficient for the buffer loaded / unloaded cases, following the highlight overhaul. lua/nvim-tree/renderer/decorator/opened.lua correctly determines the loaded state.

It is not sufficient for the no_buffer filter, on load and unload.

alex-courtis added a commit that referenced this issue Apr 7, 2025
alex-courtis added a commit that referenced this issue Apr 7, 2025
alex-courtis added a commit that referenced this issue Apr 7, 2025
@alex-courtis
Copy link
Member

@KH9IZ many thanks for finding this one; it's a big performance hit.

I'd be most grateful if you thoroughly tested a fix branch

cd /path/to/nvim-tree.lua
git pull
git checkout 3101-incorrect-option-read-during-BufReadPost

When you're finished testing:

git checkout master

@alex-courtis alex-courtis added the reproduced Issue confirmed label Apr 7, 2025
@KH9IZ
Copy link
Author

KH9IZ commented Apr 7, 2025

@alex-courtis Yeah, that's much better. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproduced Issue confirmed
Projects
None yet
2 participants