nvim-telescope / telescope.nvim

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

Filtering on paths does not work if you use "smart" as path_display #2360

Open danielo515 opened 1 year ago

danielo515 commented 1 year ago

Description

When you use path_display = { "smart" } for any picker, specially grep, it is not possible to filter the results using the path. Other methods (truncate, absolute, etc) seem to work just fine

Neovim version

NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura-arm64.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.2/share/nvim"

Operating system and version

macOS 13.1

Telescope version / branch / rev

0b1c41a

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 13.0.0
  - OK: fd: found fd 8.6.0

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

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

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

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

## Telescope Extension: `frecency`
  - OK: sql.nvim installed.

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

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

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

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

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

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

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

Steps to reproduce

  1. run telescope.grep_files with any search string and using path_display = { "smart" }
  2. try to filter based on file path

Expected behavior

Being able to filter based both on path and result text. For example

Actual behavior

path_display = { "smart" } does not allow to filter by path, only by result text

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()
  require('telescope').setup()
  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()]]
skoch13 commented 10 months ago

It looks like the very same bug applied to 'truncate' behavior.

jamestrew commented 10 months ago

I can't reproduce either of this. I'm also fairly confident that there is no bug here. The transforming for the path using path_display option has no baring on the ordinal value used to do the filtering.

I would need a proper minimal config and reproduction steps (describe creating the files to search, etc) to convince me otherwise.

skoch13 commented 10 months ago

@jamestrew my STR are:

jamestrew commented 10 months ago

That isn't really an adequate minimal config or instructions..,

Here's the min config I tried

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.loop.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",
      "natecraddock/telescope-zf-native.nvim",
    },
    config = function()
      require("telescope").setup({
        defaults = {
          path_display = { "truncate" },
        },
      })

      require("telescope").load_extension("zf-native")
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

If you'd like me to volunteer my free time to this, you would need to provide some evidence that this bug actually exists by demonstrating that it's actually reproduce-able using a minimal config like above, with clear instructions.

skoch13 commented 10 months ago

I appreciate your generous contribution of time and effort, @jamestrew. Your minimal configuration seems to be correct. However, the crucial element of my reproduction relies on the utilization of the find_files picker. It works as intended until the truncate policy is applied to the search results. Specifically, in most of my tests, this problem occurs when the search query includes the space operator, which acts as a narrowing delimiter for zf.

jamestrew commented 10 months ago

Yeah that's what I'm trying but I can't reproduce it. Unless I'm misinterpreting something...

https://github.com/nvim-telescope/telescope.nvim/assets/66286082/3e79de52-2b15-4d03-91c4-dd45faf06836

skoch13 commented 10 months ago

@jamestrew thank you. Unfortunately, I cannot share the exact file paths, but there are screenshots that illustrate that behavior.

I hope it helps 😬