nvim-telescope / telescope.nvim

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

Telescope buffers incorrect path_display after commit 3b8399c #2997

Open sibouras opened 7 months ago

sibouras commented 7 months ago

Description

bofore 3b8399c Telescope buffers path_display={'smart'} used to show relative paths, now it shows absolute paths with tilde

Neovim version

NVIM v0.10.0-dev-2559+g3814750d3
Build type: RelWithDebInfo
LuaJIT 2.1.1707061634

Operating system and version

windows 11

Telescope version / branch / rev

221778e

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 (rev e50df40a19)
- OK fd: found fd 9.0.0

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Steps to reproduce

:Telescope buffers path_display={'smart'}

Expected behavior

image

Actual behavior

image

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()]]
jamestrew commented 7 months ago

Can you give this PR a try? https://github.com/nvim-telescope/telescope.nvim/pull/2999

jamestrew commented 7 months ago

I wrote some unit tests (and ran them against Windows with github actions) for the function related to handling path_display here: https://github.com/nvim-telescope/telescope.nvim/pull/3013

I think I was able to fix the 'smart' option for path_display that was previously broken but I didn't find anything out of the ordinary for the 'shorten' and default '' option. Looks like I'll have to dust off my windows machine to debug this some more.

sibouras commented 7 months ago

the smart option works great now for the non git pickers, but git_files and git_status are still broken for smart, shorten and the default ''

and there's a weird behavior with git_status path_display={'smart'}, it kinda works: the first time i run it the first result is bugged and files in the first level root directory like init.lua and lazy-lock.json are not supposed to be prefixed by ..\nvim\

here's a video to better show what's happening and maybe save you from touching windows:

https://github.com/nvim-telescope/telescope.nvim/assets/64098483/4b76318a-06a5-4cd2-8555-358a98359d1a

jamestrew commented 7 months ago

Hmm... I starting to wonder if this is git setting related. Doing git status on Windows powershell gives me unix style paths. image This combined with the fact that vim.loop.cwd gives me Windows path and the way we "carelessly" combined join them gives me a :Telescope git_status path_display={''} like this image this is BEFORE 3b8399c (on c816406)

I'm not sure how it wasn't broken for you before.

sibouras commented 7 months ago

the most recent plenary commit https://github.com/nvim-lua/plenary.nvim/pull/551 broke :Telescope git_status path_display={''} on c816406, try using the commit before it

jamestrew commented 7 months ago

Ahh... nice find. I see the issue now I believe - although the plenary change complicates things a little despite it having the right intentions. Man windows paths are finicky 😅

sibouras commented 7 months ago

tell me about it lol