nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.49k stars 825 forks source link

selection_strategy = 'row' doesn't work with `descending` #2006

Open asgeo1 opened 2 years ago

asgeo1 commented 2 years ago

Description

I recently updated Telescope to latest, after having not updated for a few months.

Something has changed. The find_files is not producing the results I would expect anymore.

I'm working on a large "mono repo" project, where in the repo there is a Ruby on Rails API, and a React frontend, and an Objective-C native iOS client too.

So that's a lot of code, but previously there was no issue. Telescope would fuzzy match across the entire repo.

Where as now, it still does that, but gets the matches wrong!

I type in route and I should see as the first match is api/config/routes.rb, which is the main Routes file from Ruby-on-Rails.

It doesn't pick this up anymore. As far as I can tell, the issue is being caused by selection_strategy = 'row', which is the only thing I am customising per the default "minimal" setup.

I'm setting selection_strategy = 'row', because I want a mapping to delete buffers when I use :lua require('telescope.builtin').buffers(), and I don't want the row position to change after I delete a buffer. (this should be the default behaviour IMO, but that's a side-issue)

Neovim version

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

Operating system and version

macOS 12.3.1

checkhealth telescope

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - WARNING: nvim-treesitter not found. 

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.3.0

## ===== Installed extensions =====

## Telescope Extension: `fzf`
  - INFO: No healthcheck provided

Steps to reproduce

  1. Clone example Rails project: git clone git@github.com:gothinkster/rails-realworld-example-app.git
  2. cd rails-realworld-example-app
  3. nvim -nu minimal.lua
  4. :lua require('telescope.builtin').find_files()
  5. type in route

Expected behavior

Should see config/routes.rb as the first match

Actual behavior

Seemingly random file appears in the fuzzy results.

image

Commenting out selection_strategy = "row", from setup, and restarting Vim fixes the issue.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  local actions = require 'telescope.actions'
  require('telescope').setup({
    defaults = {
      selection_strategy = "row",
      mappings = {
        i = { ["<C-d>"] = actions.delete_buffer },
      },
    },
  })
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
Conni2461 commented 2 years ago

I'm setting selection_strategy = 'row', because I want a mapping to delete buffers when I use :lua require('telescope.builtin').buffers(), and I don't want the row position to change after I delete a buffer. (this should be the default behaviour IMO, but that's a side-issue)

This is the current behavior, you dont have to setup anything. Here is a clip: https://asciinema.org/a/vKZaYHDZ6DKuNJOTDN23u0db4

You can also just setup a selection_strategy for one specific picker. See :help telescope.setup

Still row seems to be broken with sorting_strategy = "descending", works with ascending thought, so works with dropdown theme. You currently have to manually scroll down to find your result: config/routes.rb

Sorry for the late response :) Will look into fixing it