sort_lastused selection behavior
Description
When using buffers picker with sort_lastused option enabled, entry at index 2 stays selected until only one entry left, even though there's better match at index 1. With additional option 'ignore_current_buffer` enabled selection works as expected.
Neovim version
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1720049189
Operating system and version
arch linux
Telescope version / branch / rev
master branch commit 5972437
checkhealth telescope
telescope: require("telescope.health").check()
Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.
Checking external dependencies ~
- OK rg: found ripgrep 14.1.0
- OK fd: found fd 10.1.0
===== Installed extensions ===== ~
Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured
Steps to reproduce
nvim -nu minimal.lua- open some buffers
- run
Telescope buffers sort_lastused=true - start typing
Expected behavior
After start typing in buffers picker with sort_lastused option enabled, selection goes to entry at index 1.
Actual behavior
https://github.com/user-attachments/assets/675b79b5-dc3f-4c24-bdce-db10dde68364
With ignore_current_buffer enabled:
https://github.com/user-attachments/assets/6f4569ee-abd5-40cf-8cee-6d1610cd63c6
Minimal config
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.uv.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 = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
require("telescope").setup {}
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
I misinterpreted the issue in #3289 Looks like the selection starting on the second entry is correct -- just shouldn't say like that.