nvim-telescope / telescope.nvim

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

Builtin buffer picker highlights flags column when searching #3240

Open bedlamzd opened 3 months ago

bedlamzd commented 3 months ago

Description

When searching for a symbol that appears both in flags column and filename, highlight applies to the former. Appears to be because it finds this symbol first.

At first I thought that flags are searchable (and I would love that) but after some investigation found out this bug

Neovim version

NVIM v0.10.1
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189

Operating system and version

fedora 40 (under WSL)

Telescope version / branch / rev

3b1600d

checkhealth telescope

──────────────────────────────────────────────────────────────────────────────
telescope: require("telescope.health").check()

Checking for required plugins
- OK plenary installed.
- WARNING nvim-treesitter not found. (Required for `:Telescope treesitter`.)

Checking external dependencies
- OK rg: found ripgrep 14.1.0
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

===== Installed extensions =====

Steps to reproduce

  1. create multiple files with "h" in the name
  2. inside neovim open the files so that they become hidden buffers
  3. open buffers picker with :lua require("telescope.builtin").buffers()
  4. try to search for a string that starts with "h"

Expected behavior

Highlight applies to filename only like that: image

Actual behavior

Here I have some hidden buffers: image

When I type "h" that is present in file names: image

Weirdly when typing more behavior differs between entries: image

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",
})
Tal500 commented 3 months ago

For me, navigating through "tab" between the result, and then pressing "enter" gets me to the previous selection. However, if I switch from insert mode and then use j/k keys to navigate, if I press "enter" I get into the right result (the one the is currently selected/highlighted).

Maybe this is a related issue

Update: This was reported in #3192 , but I still think that this issues can be related somehow

jamestrew commented 3 months ago

I'm able to reproduce this but this would probably be tricky to fix.

@Tal500 seems unrelated. #3192 is only specific to the git status picker.

Tal500 commented 3 months ago

I'm able to reproduce this but this would probably be tricky to fix.

@Tal500 seems unrelated. #3192 is only specific to the git status picker.

Perhaps than it's a new issue

Tal500 commented 3 months ago

I'm able to reproduce this but this would probably be tricky to fix.

@Tal500 seems unrelated. #3192 is only specific to the git status picker.

Sorry, you were right, I didn't understand the multipicking feature of TAB