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

Files with brackets in the name fail to open #1303

Closed
itmecho opened this issue Oct 4, 2021 · 2 comments
Closed

Files with brackets in the name fail to open #1303

itmecho opened this issue Oct 4, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@itmecho
Copy link

itmecho commented Oct 4, 2021

Description

If you have a file with brackets in the name, for example pages/api/user/[id].ts, it fails to open via telescope's find_files or file_browser.

Opened with telescope, I see this

:echo expand('%')
/pages/api/user/[id].ts

opened via :e using tab completion where it auto escapes the first bracket, I see this:

:e pages/api/auth/\[...nextauth].ts
:echo expand('%')
pages/api/auth/[...nextauth].ts

Neovim version

NVIM v0.6.0-dev+324-ge8fb0728e
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/iain/src/neovim/build/config -I/home/iain/src/neovim/src -I/home/iain/src/neovim/.deps/usr/include -I/usr/include -I/home/iain/src/neovim/build/src/nvim/auto -I/home/iain/src/neovim/build/include
Compiled by iain@orion

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/home/iain/.local/share/nvim"

Operating system and version

Arch linux Linux orion 5.14.7-arch1-1 #1 SMP PREEMPT Wed, 22 Sep 2021 21:35:11 +0000 x86_64 GNU/Linux

checkhealth telescope

health#telescope#check
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.2.1

## ===== Installed extensions =====

## Telescope Extension: `fzy_native`
  - INFO: No healthcheck provided

Steps to reproduce

  1. cd /tmp && echo 'test' > '[test].txt'
  2. Open neovim with telescope installed
  3. :Telescope find_files or :Telescope file_browser
  4. Search for test and select the file from step 1
  5. See an empty buffer

Expected behavior

Should open the correct file

Actual behavior

Opens a blank buffer (I'm guessing a new file?)

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()]]
@itmecho itmecho added the bug Something isn't working label Oct 4, 2021
@fdschmidt93
Copy link
Member

fdschmidt93 commented Oct 4, 2021

Closing this as a duplicate of #1223 and #1291 being tracked over at #1171

Just to check, :e pages/api/auth/\[...nextauth].ts already solves the problem? If that already solves it, my first hunch is the below would have to be extended to properly escape these filenames adequately. I'm quite busy atm, happy to guide a PR.

if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
pcall(vim.cmd, string.format("%s %s", command, filename))

cc also @MatthiasGrandl @efierros @lgmys -- if one of the four of you in total wants to take a crack at this :)

@MatthiasGrandl
Copy link

@fdschmidt93 yes opening the file like that works as expected. Sadly I have very little lua knowledge and am quite busy myself.

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

No branches or pull requests

3 participants