Skip to content

Specifying default_selection_index that is larger than picker window does not work #3492

@dtor

Description

@dtor

Description

Over the years there were several fixes for issues related to [re]drawing the picker window:

#1757
#2697
#2667

Unfortunately the fixes result in moving the cursor to either first or last line in the buffer, ignoring the desired selection index. Manually scrolling up or down moves the cursor position into the right place.

I think the simplest way to fix this is to move to { self._selection_row + 1, 0 } instead of { self.max_results, 1 } (by the way, why 1?) or { 1, 0 } (depending on the sort option).

Neovim version

NVIM v0.11.1-dev-66+ge342b9a25a
Build type: Release
LuaJIT 2.1.1741730670

Operating system and version

Linux

Telescope version / branch / rev

master

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.1
- ✅ OK fd: found fdfind 10.2.0

===== Installed extensions ===== ~

Telescope Extension: `file_browser` ~
- No healthcheck provided

Telescope Extension: `fzf` ~
- ✅ OK lib working as expected
- ✅ OK file_sorter correctly configured
- ✅ OK generic_sorter correctly configured

Steps to reproduce

Create a custom picker based on a table providing many entries and set sufficiently large default_selection_index. Observe the cursor on the 1st line instead of scrolling to the desired entry.

Expected behavior

Cursor is positioned at the right entry.

Actual behavior

Observe the cursor on the 1st line instead of scrolling to the desired entry (assuming ascending sort option).

Minimal config

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions