Closed tummetott closed 1 month ago
Started to migrate to v3, experiencing the same issue
That's actually because of the default sort for some sources.
This is the default for diagnostics
for example:
sort = { { buf = 0 }, "severity", "filename", "pos", "message" },
The first item of the sorter will sort items from your current buffer to the top.
You can change it with:
{
modes = {
diagnostics = {
sort = { "severity", "filename", "pos", "message" },
}
}
}
I'll keep this issue open for now, since the default doesn't work well indeed for going to next/previous items
And quickfix
is the same as qflist
.
I don't fully rememeber, but I probably kept that for backward compatibility.
would it make sense then to make the following defaults?
modes = {
telescope = {
sort = { "pos", "filename", "severity", "message" },
},
quickfix = {
sort = { "pos", "filename", "severity", "message" },
},
loclist = {
sort = { "pos", "filename", "severity", "message" },
},
todo = {
sort = { "pos", "filename", "severity", "message"}
},
}
I guess it makes sense for diagnostics that they sort every time you move or jump inside the list, since fixing lsp errors is a continuous task. But for quickfix, loclist, todo comments (which have imho no severity?) and telescope results its quite confusing when the order changes every time you move
Changed all the views to remove the buf = 0
, so should no longer happen
What was the default sort behavior in the old version of trouble? My workflow is the following:
grep_string
require("trouble.sources.telescope").open
)require("trouble").next({skip_groups = true, jump = true})
to jump to next entries in the list:Trouble telescope toggle
in the old version of trouble, the order was preserverd. it behaved just like the native vim qflist. how must i configure the sorter, so the order is not changed, even after closing and opening trouble again?
@tummetott seems I forgot to remove that buf = 0
filter for telescope. Fixed now.
Or maybe in other words. How can i preserve the order that telescope shows me after typing a query? When sending items of a telescope search to a native qflist, the order is the one from telescope. in trouble, i can sort by filetype (which is the behavior of the old trouble) or by pos
. but pos
does not keep the order of telescope
You can try opts.modes.telescope.sort = {}
. Not 100%, but this probably does use the order of items as you saw it in Telescope.
You'll probaly also have to set opts.modes.telescope.groups = {}
.
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.9.5 Build type: Release LuaJIT 2.1.1703358377
Operating system/version
MacOs 14.2.1
Describe the bug
Lets say I have the 4 files
a
b
c
,d
opened in a trouble window (e.g. from Telescope from a Quickfix list, it does not matter). When I execute:lua require'trouble'.next({jump=true})
a few times, the order of the trouble list changes.Steps To Reproduce
mkdir test && cd test
touch a b c d
nvim -u path/to/repro.lua
:Telescope find_files
<C-q>
to open all files in a trouble window:lua require'trouble'.next({jump=true})
:lua require'trouble'.next({jump=true})
--> The order is already messed upthis also happens with quickfix lists.
BTW: what is the difference between
:Trouble qflist
and:Trouble quickfix
?? i can open two trouble windows, showing the same content?Expected Behavior
Order should not change.
Repro