Skip to content

find_file can put the cursor below the correct line when group_empty is enabled #2433

Closed
@przepompownia

Description

@przepompownia

Description

As in the title, nothing more.

Neovim version

LuaJIT 2.1.
Build type: RelWithDebInfo
NVIM v0.10.0-dev-1199+g9637b7dae


### Operating system and version

Debian Sid

### nvim-tree version

07eb5b4

### Clean room replication

```lua
local configDir = vim.fn.expand('<sfile>:p:h')

vim.env['XDG_CONFIG_HOME'] = configDir
vim.env['XDG_DATA_HOME'] = configDir .. '/.xdg/data'
vim.env['XDG_STATE_HOME'] = configDir .. '/.xdg/state'
vim.env['XDG_CACHE_HOME'] = configDir .. '/.xdg/cache'
local stdPathConfig = vim.fn.stdpath('config')

vim.opt.runtimepath:prepend(stdPathConfig)
vim.opt.packpath:prepend(stdPathConfig)
local plugins_path = vim.fn.fnamemodify('plugins/', ':p')

for name, url in pairs{
  ['nvim-tree'] = 'https://github.com/nvim-tree/nvim-tree.lua',
} do
  local install_path = plugins_path .. name
  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

local root = configDir
local cwd = configDir .. '/home/foo/dev/foo'

vim.fn.mkdir(cwd, 'p')
vim.fn.writefile({}, configDir .. '/home/foo/bar')
vim.api.nvim_set_current_dir(cwd)

require('nvim-tree').setup {
  renderer = {
    group_empty = true,
  },
  git = { enable = false }, -- not necessary
}

local function test()
  local treeapi = require('nvim-tree.api')
  treeapi.tree.open(root)
  treeapi.tree.find_file(cwd)
end

test()

vim.keymap.set('n', ',m', test)

Steps to reproduce

Put the above init.lua in some new directory (to easy clean up after) and run .../path/to/nvim --clean -u init.lua.

Expected behavior

The cursor lands on cwd (home/foo/dev/foo).

Actual behavior

image

The cursor lands on bar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreproducedIssue confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions