trouble.nvim icon indicating copy to clipboard operation
trouble.nvim copied to clipboard

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

Open cameronr opened this issue 1 year ago • 13 comments

Did you check docs and existing issues?

  • [X] I have read all the trouble.nvim docs
  • [X] I have updated the plugin to the latest version before submitting this issue
  • [X] I have searched the existing issues of trouble.nvim
  • [X] 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:

https://github.com/folke/trouble.nvim/blob/3dc00c0447c016cd43e03054c3d49436a1f2076d/lua/trouble/view/main.lua#L48-L50

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

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,
    },
  },
})

cameronr avatar Nov 16 '24 21:11 cameronr

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.

github-actions[bot] avatar Dec 17 '24 02:12 github-actions[bot]

This still repros so i think is still an issue.

cameronr avatar Dec 17 '24 05:12 cameronr

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.

github-actions[bot] avatar Jan 18 '25 01:01 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar Jan 18 '25 23:01 cameronr

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.

github-actions[bot] avatar Feb 19 '25 01:02 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar Feb 19 '25 15:02 cameronr

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.

github-actions[bot] avatar Mar 22 '25 02:03 github-actions[bot]

This bot is causing trouble 😁.

andradei avatar Mar 25 '25 22:03 andradei

stale and ignored are two different things, but are treated the same by this bot, apparently.

andradei avatar Mar 25 '25 23:03 andradei

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.

github-actions[bot] avatar Apr 25 '25 02:04 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar Apr 25 '25 15:04 cameronr

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.

github-actions[bot] avatar May 26 '25 02:05 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar May 26 '25 15:05 cameronr

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.

github-actions[bot] avatar Jun 26 '25 02:06 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar Jun 26 '25 05:06 cameronr

This tag game with the bot is painfully funny.

andradei avatar Jul 01 '25 02:07 andradei

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.

github-actions[bot] avatar Jul 31 '25 02:07 github-actions[bot]

This still reproduces so I think should be left open.

cameronr avatar Jul 31 '25 03:07 cameronr

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.

github-actions[bot] avatar Sep 26 '25 02:09 github-actions[bot]

still a bug

cameronr avatar Sep 26 '25 03:09 cameronr

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.

github-actions[bot] avatar Oct 27 '25 02:10 github-actions[bot]

still a bug

cameronr avatar Oct 27 '25 02:10 cameronr