Skip to content

OptionSet is triggered when tree open in some cases. #2334

@peter-lyr

Description

@peter-lyr

Description

I like the tree to stay open, but one day I run nvim-qt in a somewhat underperforming Windows 10 computer, I found out that every time I open the tree, I get stuck until I close the tree.

Then I tried to find out what causes it to be stuck, in other words, what makes OptionSet to be triggered repeatedly.

Neovim version

NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Windows 10, Windows 11

nvim-tree version

3b62c6b

Clean room replication

for name, url in pairs {
  tree = 'https://github.com/nvim-tree/nvim-tree.lua.git',
  devicons = 'https://github.com/nvim-tree/nvim-web-devicons.git',
} do
  local install_path = vim.fn.fnamemodify([[C:\Users\llydr\Desktop\nv\nvt-min\]] .. name, ':p') -- TODO: Please change the path here!!!
  if vim.fn.isdirectory(install_path) == 0 then vim.fn.system { 'git', 'clone', '--depth=1', url, install_path } end
  vim.opt.runtimepath:append(install_path)
end

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

require('nvim-tree').setup()
print 'Minimal Config Ready!'

local file = [[C:\Users\llydr\Desktop\nv\nvt-min\nvt-min.log]] -- TODO: Please change the path here!!!
vim.api.nvim_create_autocmd({ "CursorMoved", "TextChanged", "OptionSet", }, {
  callback = function(ev)
    vim.fn.writefile({ string.format([[%-3.3f %-2d %-20s - "%s"]], os.clock(), ev.buf, ev.event, ev.file) }, file, 'a')
  end
})

Steps to reproduce

  1. cd C:\Users\llydr\Desktop\nv\nvt-min
  2. which nvim

/c/Users/llydr/Desktop/nv/nvim-win64/bin/nvim

  1. nvim -nu nvt-min.lua
  2. :NvimTreeOpen
  3. press - to go Up or press <c-]> to CD into some folder.
  4. observe whether the nvt.min.log file keeps growing.
  5. When I type :NvimTreeOpen and press Enter, it just keeps getting bigger and bigger.

Expected behavior

When the tree remains open, regardless of whether the tree is active or inactive, and regardless of whether the tree is focused lost or gained, the OptionSet is not triggered repeatedly.

Actual behavior

CursorMoved, TextChanged, OptionSet are triggered repeatedly.

It will not be always triggered.

For example, when the tree is:

~\Desktop\nv\nvt-min/..
  devicons
  tree
  󰌱 nvt-min.log
   nvt-min.lua

or

~\Desktop\nv\nvt-min/..
  devicons
  tree
    .git
    .github
    .hooks
    doc
    lua
    scripts
     .editorconfig
     .luacheckrc
     .luarc.json
     .stylua.toml
     CONTRIBUTING.md
     LICENSE
     README.md
  󰌱 nvt-min.log
   nvt-min.lua

They would be triggered.

But when I CD into tree or devicons, They would not be triggered.
Like this:

~\Desktop\nv\nvt-min\tree/..
  .git
  .github
  .hooks
  doc
  lua
  scripts
   .editorconfig
   .luacheckrc
   .luarc.json
   .stylua.toml
   CONTRIBUTING.md
   LICENSE
   README.md

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions