Skip to content
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

feature: Remembering Current Entry State After Toggling Trouble Window #367

Open
1 task done
tummetott opened this issue Dec 11, 2023 · 11 comments
Open
1 task done
Labels
bug v3 enhancement New feature or request

Comments

@tummetott
Copy link

Did you check the docs?

  • I have read all the trouble.nvim docs

Is your feature request related to a problem? Please describe.

Hello,

I have completely replaced my Quickfix list with Trouble, and I love its features. However, there is one thing that bothers me. Trouble doesn't seem to remember its current entry when I toggle it off and on again. In contrast, the native Quickfix window remembers its current entry when toggling with cclose and copen.

Describe the solution you'd like

Trouble remembers it's current entry

Describe alternatives you've considered

Additional context

No response

@tummetott tummetott added the enhancement New feature or request label Dec 11, 2023
@belorenz
Copy link

Upvote!

@simserino
Copy link

Upvote

@engebeni
Copy link

Upvote!

@tylernewnoise
Copy link

Upvote

@juliangoetze
Copy link

Upvote!
It would also be awesome to get the ability to call require("trouble").next({skip_groups = true, jump = true}); for the last active Trouble Instance, even if the Trouble list isn't toggled at the moment. The same way that you would use :cn or :cp with the quickfix-list while it's not opened. Maybe worth an issue..

@tummetott
Copy link
Author

When i saw that trouble v3 is released, i was hoping to much this feature would be included. But apparently it doesn't. When toggeling the quickfix with require('trouble').toggle('quickfix'), there is always the first entry selected

@folke
Copy link
Owner

folke commented Mar 29, 2024

Added and enabled by default.
Be aware that this setting might conflict with follow, so you may want to also set follow=false depending your use-case

@folke folke closed this as completed Mar 29, 2024
@folke folke added the fixed v3 label Mar 29, 2024
@tummetott
Copy link
Author

Not working for me.

consider this minimal config:

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

-- set stdpaths to use .repro
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",
        branch = "dev",
        lazy = false,
        opts = {
            follow = false,
            restore = true,
            auto_preview = false,
            auto_refresh = false,
        },
    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Then I open nvim with: nvim -u repro.lua repro.lua

  1. :grep vim repro.lua Populates the qflist
  2. :Trouble quickfix toggle focus
  3. Go down a few entries and press <CR> to jump to a qf-entry
  4. :Trouble quickfix toggle
  5. :Trouble quickfix toggle
    --> cursorline is on the first line again

@folke
Copy link
Owner

folke commented Mar 29, 2024

Should be fixed now. The problem was that qf items did not have a unique id, so the check on re-open failed to find the previously selected entry

@folke folke closed this as completed Mar 29, 2024
@tummetott
Copy link
Author

unfortunately still not working with the same example

@folke folke reopened this Mar 29, 2024
@folke folke added bug v3 and removed fixed v3 labels Mar 29, 2024
@rgauselumifi
Copy link

Upvote! It would also be awesome to get the ability to call require("trouble").next({skip_groups = true, jump = true}); for the last active Trouble Instance, even if the Trouble list isn't toggled at the moment. The same way that you would use :cn or :cp with the quickfix-list while it's not opened. Maybe worth an issue..

UPVOTE!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v3 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants