Skip to content

bug: Statusline symbols from previous buffer shown on buffer with buftype = 'nofile' #602

Closed as not planned

Description

@cameronr

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.2 Build type: Release LuaJIT 2.1.1727870382

Operating system/version

MacOS 15.0.1

Describe the bug

Statusline symbols from a previous buffer are shown on the current buffer if the buftype of the current buffer is 'nofile'. First noticed when using Neogit but also happens with :checkhealth:

Screenshot 2024-11-16 at 13 42 09
Screenshot 2024-11-16 at 13 42 15

In the above example, :=require('trouble.view.main'):get() returns:

{
  buf = 1,
  cursor = { 15, 0 },
  filename = "/Users/cam/.local/share/nvim-cam/lazy/trouble.nvim/lua/trouble/config/init.lua
",
  win = 1000
}

:=require('trouble.view.main')._main:

{
  buf = 1,
  cursor = { 15, 0 },
  filename = "/Users/cam/.local/share/nvim-cam/lazy/trouble.nvim/lua/trouble/config/init.lua
",
  win = 1005
}

:=require('trouble.view.main')._buf:

nil

It seems like it's happening because buffers with buftype ~= "" are being ignored. Commenting out this buftype ~= "" check fixes it:

if vim.bo[buf].buftype ~= "" then
return false
end

But I don't know if that's the "right" way to fix it.

EDIT: Finally got around to looking at this more closely. I think the right fix is to only look for windows up to the current tabpage rather than all windows. PR #652

Steps To Reproduce

  1. nvim -u repro.lua lua/trouble/config/init.lua
  2. Wait for lua_ls to index project
  3. place the cursor on a line that displays symbols on the statusline (e.g. lua/trouble/config/init.lua:15)
  4. run :checkhealth

Note: I was getting some weirdness where mason wouldn't correctly install lua_ls with repro.lua. If you get an error about lua_ls, just :MasonInstall lua-language-server to fix it.

Expected Behavior

No statusline symbols are displayed for the health window

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    -- minimal mason/lsp setup
    {
      "neovim/nvim-lspconfig",
      dependencies = {
        "williamboman/mason.nvim",
        "williamboman/mason-lspconfig.nvim",
        -- just for ls status
        { "j-hui/fidget.nvim", opts = {} },
      },
      config = function()
        require("mason").setup()

          require("mason-lspconfig").setup({
            ensure_installed = { "lua_ls" },
            handlers = {
              function(server_name)
                require("lspconfig")[server_name].setup({})
              end,
            },
          })
      end,
    },
    { "folke/trouble.nvim", opts = {} },
    {
      "nvim-lualine/lualine.nvim",
      opts = function()
        local trouble = require("trouble")
        local symbols = trouble.statusline({
          mode = "lsp_document_symbols",
          groups = {},
          title = false,
          filter = { range = true },
          format = "{kind_icon}{symbol.name:Normal}",
          -- The following line is needed to fix the background color
          -- Set it to the lualine section you want to use
          hl_group = "lualine_c_normal",
        })
        return {
          sections = {
            lualine_c = {
              { "filename" },
              {
                symbols.get,
                cond = symbols.has,
              },
            },
          },
        }
      end,
    },
  },
})

Activity

  1. github-actions commented on Dec 17, 2024

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  2. cameronr commented on Dec 17, 2024

    @cameronr
    Author

    This still repros so i think is still an issue.

  3. removed
    staleThis issue or PR has been inactive for a while
    on Dec 18, 2024
  4. github-actions commented on Jan 18, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  5. cameronr commented on Jan 18, 2025

    @cameronr
    Author

    This still reproduces so I think should be left open.

  6. removed
    staleThis issue or PR has been inactive for a while
    on Jan 19, 2025
  7. github-actions commented on Feb 19, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  8. cameronr commented on Feb 19, 2025

    @cameronr
    Author

    This still reproduces so I think should be left open.

  9. removed
    staleThis issue or PR has been inactive for a while
    on Feb 20, 2025
  10. github-actions commented on Mar 22, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  11. 20 remaining items

  12. added a commit that references this issue on Aug 26, 2025
    98a1fe8
  13. github-actions commented on Sep 26, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  14. cameronr commented on Sep 26, 2025

    @cameronr
    Author

    still a bug

  15. removed
    staleThis issue or PR has been inactive for a while
    on Sep 27, 2025
  16. github-actions commented on Oct 27, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  17. cameronr commented on Oct 27, 2025

    @cameronr
    Author

    still a bug

  18. removed
    staleThis issue or PR has been inactive for a while
    on Oct 28, 2025
  19. github-actions commented on Nov 27, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  20. github-actions commented on Dec 4, 2025

    @github-actions
    Contributor

    This issue was closed because it has been stalled for 7 days with no activity.

  21. added a commit that references this issue on Jun 16, 2026
    e1b05b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleThis issue or PR has been inactive for a whilewontfixThis issue will not be fixed or implemented

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions