-
-
Notifications
You must be signed in to change notification settings - Fork 847
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pickers): sorting_strategy=asc stale result clearing (#3298)
With `sorting_strategy='ascending'`, the results buffer should never have lines beyond the `max_results` count OR the number of available results, whichever is smaller. closes #3282
- Loading branch information
Showing
3 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
if vim.fn.has "mac" == 1 or require("telescope.utils").iswin then | ||
return | ||
end | ||
|
||
local tester = require "telescope.testharness" | ||
|
||
local disp = function(val) | ||
return vim.inspect(val, { newline = " ", indent = "" }) | ||
end | ||
|
||
describe("builtin.live_grep", function() | ||
for _, configuration in ipairs { | ||
{ sorting_strategy = "descending" }, | ||
{ sorting_strategy = "ascending" }, | ||
} do | ||
it("clears results correctly when " .. disp(configuration), function() | ||
tester.run_string(string.format( | ||
[[ | ||
runner.picker( | ||
"live_grep", | ||
"abcd<esc>G", | ||
{ | ||
post_typed = { | ||
{ | ||
5, | ||
function() | ||
return #vim.tbl_filter(function(line) | ||
return line ~= "" | ||
end, GetResults()) | ||
end, | ||
}, | ||
}, | ||
}, | ||
vim.tbl_extend("force", { | ||
sorter = require("telescope.sorters").get_fzy_sorter(), | ||
layout_strategy = "center", | ||
cwd = "./lua/tests/fixtures/live_grep", | ||
temp__scrolling_limit = 5, | ||
}, vim.json.decode [==[%s]==]) | ||
) | ||
]], | ||
vim.json.encode(configuration) | ||
)) | ||
end) | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
abc | ||
abc | ||
abc | ||
abc | ||
abc | ||
|
||
|
||
abcd | ||
abcd | ||
abcd | ||
abcd | ||
abcd | ||
|
||
abcde |