Skip to content

Conversation

@simonmandlik
Copy link
Collaborator

This PR fixes a bug introduced in #3214

In grow() when M.View.root_excluded is true lines starts from the second line, but later in the for loop we index starting from 1 always.

…dth in `grow` when `nvim-tree.view.width.lines_excluded` contains "root"
@alex-courtis
Copy link
Member

Thanks for looking after this one @simonmandlik

This looks right, however I cannot identify the bug. Can you please decscribe how to reproduce it so that I can test?

@simonmandlik
Copy link
Collaborator Author

There are several ingredients needed:

  • use right-aligned icons
  • use the root for width computation
  • have an icon shown on the widest item

Before the fix:

image

With the fix:

image
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",
      "nvim-tree/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

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup({
    view = {
      width = {
        min = 0,
        padding = 0,
        lines_excluded = {},
      }
    },
    renderer = {
      icons = {
        git_placement = "right_align",
      }
    }
  })
end

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.

Tested OK, love your work as always @simonmandlik

@alex-courtis alex-courtis changed the title fix: misaligned extmarks fix: incorrect window width when right_align icons present Jan 11, 2026
@alex-courtis alex-courtis merged commit e66994d into master Jan 11, 2026
5 checks passed
@alex-courtis alex-courtis deleted the feat/misaligned_extmarks_fix branch January 11, 2026 03:56
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