folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.44k stars 177 forks source link

bug: Split preview opens all folds #459

Closed Tired-Fox closed 4 months ago

Tired-Fox commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

Windows 10 22H2

Describe the bug

When using the split preview from the examples, hovering/selected a single item opens all folds. I assume this is how the preview/trouble windows are refreshed in the split.

I tested this with type main and type float for the preview and both retain the fold state.

Steps To Reproduce

  1. trouble window is open with a preview setup with
    {
    -- ...
    preview = {
    type = "split",
    relative = "win",
    position = "right",
    size = 0.5,
    }
    -- ...
    }
  2. all folds are closed (zM)
  3. one fold is opened (za)
  4. an item is hovered/selected
  5. preview is refreshed along with the trouble window
  6. all folds are opened

Expected Behavior

When hovering/selecting an item the folds stay folded.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repo
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/trouble.nvim",
  -- add any other plugins here
  {
    "nvim-telescope/telescope.nvim",
    tag = "0.1.8",
    name = "telescope",
    dependencies = {
      "nvim-lua/plenary.nvim",
    }
    config = function()
        require("telescope").setup({
      defaults = {
        mappings = {
        n = { ["<c-t>"] = open_with_trouble },
        },
         }
        })
    end
  }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
Tired-Fox commented 3 months ago

🎊