nvim-telescope / telescope.nvim

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

builtin.git_status doesn't handle quoted file names #3284

Open Lattay opened 1 month ago

Lattay commented 1 month ago

Description

If git status produces a quoted file name (if the file name contain a space for example) the builtin picker git_status will not parse the result properly and include literal quotes in the file name.

Neovim version

NVIM v0.11.0-dev-720b309c7-dirty
Build type: Release
LuaJIT 2.1.1720049189

Operating system and version

Arch

Telescope version / branch / rev

master, current commit 5972437

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.0
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

===== 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

Telescope Extension: `ui-select` ~
- No healthcheck provided

Steps to reproduce

With minimal.lua in home directory.

mkdir repro
cd repro
git init
echo "test file" > 'file with space.txt'
nvim -nu ~/minimal.lua

Then do :lua require("telescope.builtin").git_status(), type file and <CR>.

Expected behavior

Navigate to the file file with space.txt.

Actual behavior

A new buffer named "file with space.txt" is open.

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",
})
Lattay commented 1 month ago

I am going to investigate the bug myself and try to fix it, but right now I just have time for the report.

Lattay commented 1 month ago

simple bug, easy fix :)