Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_file errors if in a folder with special characters #2675

Open
AvarianKnight opened this issue Aug 29, 2023 · 2 comments
Open

find_file errors if in a folder with special characters #2675

AvarianKnight opened this issue Aug 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@AvarianKnight
Copy link

Description

This is likely related to #2345

If a file has brackets and a dash in the name, using find_file will result in Reverse range in character class here

Applying the same fix as #2345 local cwd = vim.fn.expand(vim.fn.escape(opts.cwd or vim.loop.cwd(), "$?*[]")) fixes this issue, though I'm not entirely sure if this breaks any intentional functionality.

Neovim version

NVIM v0.10.0-dev-856+ge928161bd
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

WSL Fedora release 38 (Thirty Eight)

Telescope version / branch / rev

telescope 0.1.x

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

Steps to reproduce

  1. mkdir '[will-fail]'
  2. cd '[will-fail]'
  3. nvim inside of the directory
  4. lua require('telescope.builtin').find_files()
  5. error 😢

Expected behavior

Expect to be able to find files inside the directory

Actual behavior

If a file has brackets and a dash in the name, using find_file will result in Reverse range in character class

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()]]
@AvarianKnight AvarianKnight added the bug Something isn't working label Aug 29, 2023
@AvarianKnight
Copy link
Author

AvarianKnight commented Aug 30, 2023

This seems to be an issue in a few places, wonder if a helper for vim.fn.expand would be a better idea, though I wouldn't know where to start.

If you have '[will-fail]' with a file in it you also

  • won't be able to preview the files content, it will just show blank.
  • won't be able to use require('telescope.builtin').buffers() it'll show Reverse range in character class
  • won't be able to use require('telescope.bultin').live_grep() it'll show Reverse range in character class

@jamestrew
Copy link
Contributor

Hey yeah this is a regular occurrence I've been noticing that's been hard to fix due to how widespread our usage of expand. It's very easy to "over-fix" so to speak.

#2628

I have this PR but it looks like I might be missing some instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants