Skip to content

fix(#2392): bookmarks vertical alignment when group_empty #2402

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

Merged
merged 4 commits into from
Sep 9, 2023

Conversation

tjex
Copy link
Contributor

@tjex tjex commented Sep 4, 2023

When group_empty is enabled, marks were misaligned if one or more parent nodes were empty. See #2392

Followed the code logic as proposed here

I'm not super confident I've taken all that needs to be into account. It seems to work (see screenshots), but it got fixed quite fast, which doesn't make me confident. Please review with that in mind!..

group_empty enabled:
Screenshot 2023-09-04 at 19 04 48

group_empty disabled (showing that marks are still aligned):
Screenshot 2023-09-04 at 19 04 25

I used the below tree structure (start is just a start script I made):
Screenshot 2023-09-04 at 19 15 41

Below was the minimal config I was using:

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

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
    require("packer").startup {
        {
            "wbthomason/packer.nvim",
            "~/tjroot/dev/neovim/nvim-tree.lua",
            "nvim-tree/nvim-web-devicons",
            -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
        },
        config = {
            package_root = package_root,
            compile_path = install_path .. "/plugin/packer_compiled.lua",
            display = { non_interactive = true },
        },
    }
end
if vim.fn.isdirectory(install_path) == 0 then
    print "Installing nvim-tree and dependencies."
    vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

_G.setup = function()
    require("nvim-tree").setup {
        renderer = {
            group_empty = true
        },
    }
end

@alex-courtis alex-courtis changed the title marks now aligned when group_empty enabled - resolves #2392 fix(#2392): bookmarks vertical alignment when group_empty Sep 9, 2023
@alex-courtis
Copy link
Member

I'm not super confident I've taken all that needs to be into account.

I've added some logging and shown that the bookmarked nodes were the correct ones. It seems to be just a rendering issue which you have addressed.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution.

Test cases:

  • hide_root_folder
  • nodes not under group
  • nodes under group
  • mark group itself - marks the lowest directory node

@alex-courtis alex-courtis merged commit b856d0a into nvim-tree:master Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants