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

A Reverse range in character class error when previewing files in a folder with specific name #2233

Closed
staticssleever668 opened this issue Nov 12, 2022 · 1 comment · Fixed by #2345
Labels
bug Something isn't working

Comments

@staticssleever668
Copy link

staticssleever668 commented Nov 12, 2022

Description

When I open files with some specific characters in it's parent directory name, an error is shown and preview window is empty.

Seems to be a duplicate of closed #1584.

I've also stumbled upon this problem in the past with a different plugin: airblade/vim-rooter#122.


I thought I would fix this myself, but the problem seems to go deeper as the path seems to get expanded for a reason.

A work-around:

diff --git a/lua/telescope/from_entry.lua b/lua/telescope/from_entry.lua
index 486b57c..596b21e 100644
--- a/lua/telescope/from_entry.lua
+++ b/lua/telescope/from_entry.lua
@@ -30,7 +30,7 @@ function from_entry.path(entry, validate, escape)
     -- TODO(conni2461): we are not going to return the expanded path because
     --                  this would lead to cache misses in the perviewer.
     --                  Requires overall refactoring in previewer interface
-    local expanded = vim.fn.expand(path)
+    local expanded = path
     if (vim.fn.filereadable(expanded) + vim.fn.isdirectory(expanded)) == 0 then
       return
     end

Neovim version

NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

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

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

Run :checkhealth for more info

Operating system and version

Arch Linux

Telescope version / branch / rev

7a4ffef

checkhealth telescope

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - WARNING: nvim-treesitter not found. 

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

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

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

Steps to reproduce

  1. Run mkdir -p "telescope_test/[u-a]" && cd telescope_test && touch "[u-a]/test_file" to create an example of erroring out directory structure.
  2. Start Neovim and run :Telescope find_files.
  3. See the error appear when the test_file file gets selected.

Expected behavior

No response

Actual behavior

E5108: Error executing lua Vim:E944: Reverse range in character class
stack traceback:
        [C]: in function 'expand'
        ...packer/start/telescope.nvim/lua/telescope/from_entry.lua:33: in function 'path'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: in function 'define_preview'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:388: in function 'preview'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1075: in function 'refresh_previewer'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1028: in function 'set_selection'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:792: in function 'move_selection'
        ...acker/start/telescope.nvim/lua/telescope/actions/set.lua:39: in function 'run_replace_or_original'
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'shift_selection'
        ...cker/start/telescope.nvim/lua/telescope/actions/init.lua:87: in function 'run_replace_or_original'
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:352: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

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()]]
@staticssleever668 staticssleever668 added the bug Something isn't working label Nov 12, 2022
@darzok0914
Copy link

hi, I just stumbled into the same error, I was wondering if anyone had any update on this?

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