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

fix(picker): ensure that the selected result matches the screen display in ascending sort order #2986

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

0x7a7a
Copy link
Contributor

@0x7a7a 0x7a7a commented Mar 15, 2024

Description

The current stable version (v0.9.5) and the nightly version have different results for the cursor position on the displayed content, I don't know exactly why.

After debugging, I found that this line of code causes the cursor to move down(row+1) when sorting_strategy=ascending,this result is consistent in v0.9.5 and nightly.

ok, msg = pcall(vim.api.nvim_buf_set_lines, results_bufnr, num_results, -1, false, {})

However, when the result is displayed, the highlighted row and the cursor position are not the same, so it cannot be displayed in nightly version(by default, the second result is displayed at the top, in the same position as the cursor.).

So I think putting the cursor to the first line (i.e. highest score) again in Picker:get_result_completor fixes the problem and doesn't affect older versions.

Fixes # (issue)
#2697

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@0x7a7a 0x7a7a changed the title fix: ensure that the selected result matches the screen display in ascending sort order fix(picker): ensure that the selected result matches the screen display in ascending sort order Mar 15, 2024
@0x7a7a
Copy link
Contributor Author

0x7a7a commented Mar 15, 2024

This is more obvious if the picker is another theme.
Ex:

pickers = {
  find_files = {
    hidden = true,
    theme = 'dropdown',
    previewer = false,
    follow = true,
  },
}

@jamestrew jamestrew merged commit e9e01d6 into nvim-telescope:master Mar 15, 2024
6 checks passed
@jamestrew
Copy link
Contributor

thanks!

@jamestrew jamestrew added the backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat) label Mar 15, 2024
Conni2461 pushed a commit that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants