nvim-telescope/telescope.nvim

Parenthesis in file path doesn't open the actual file, instead opens an empty one

mez0ru opened this issue · 6 comments

Description

If I open telescope, I'm able to see the file, but its contents are empty. If I try to access the file through telescope, it opens the file as if it were an empty file, even though it contains contents.

Neovim version

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320

Operating system and version

Windows 10

Telescope version / branch / rev

@35f94f0ef32d70e3664a703cefbe71bd1456d899

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

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

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

From what I have tried, it seems I can reproduce the issue if I have a tree like this

parent/
--X/
----(Y)/
------Z

in this case X, and (Y) are folders, while Z is any file(s) inside the (Y) folder.
You should open neovim in the folder "parent" like "neovim .", then open telescope...

Expected behavior

File is opened and the actual content is shown in the editor and the preview panel in the telescope window.

Actual behavior

File appears to be empty in the telescope preview panel, upon opening the file, its content is empty too.

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()]]

With my own config:

Telescope.find_files.with.parenthesis.folder.mp4

With minimal config:

Telescope.find_files.minimal.mp4

@mez0ru is this what you are trying to achieve?

Note

I will test it in Windows soon to see if thats the problem

You forgot to create a directory above (test), and you should be in its parent directory too.
So the structure:
Parent/test/(test)/thefile.txt
^
|
(You should be here)
When you are inside "Parent" open neovim like

nvim .

And test again.

Thanks btw for the quick response!

@mez0ru I tested it with the following structure:

testgit
├── test.txt
└── testing
   └── (test)
      └── testfile.ts
Telescope.find_files.minimal.mp4

Note

The command I used is nvim -nu ~/dev/nvim_plugins/minimal_setups/telescope_minimal.lua . that equals to nvim . but using the minimal configuration.

Hello @AlejandroSuero, Sorry for the trouble.
I just tested the bug on my second pc which has Linux installed on it, using the same neovim version (with the same configuration). It seems the problem only affects windows users.
So I just confirmed myself that it only happens on windows 10 (not sure if it happens on other versions of windows).
But yeah, it's platform specific bug. But hopefully it could be fixed.
Just to clarify, telescope works. But only in this specific case, the bug occurs.
Thanks for your response.

Video demonstration:

2024-04-30.09-40-48.mp4

If is only on windows @mez0ru, I think I know what may be the problem, I will test it later in windows 11 to check if is happening there as well.

But I think that when reading the path folder\(folder)\file is escaping the first parenthesis, in Linux it will use / so I guess that's why it works like that.

Thanks @AlejandroSuero for chiming in. As suspected, this is a Windows thing that telescope isn't handling well.
We're tracking this issue here #2446

There's a partial workaround here: #2446 (comment)
A similar thing can be done for live_grep/grep_string as well.

I'll close this issue as it's essentially a duplicate.