-
-
Notifications
You must be signed in to change notification settings - Fork 842
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
Unable to preview and open files with parentheses in the path #2446
Comments
This sounds somewhat related to #2412 and by that I mean some of these javascript meta frameworks tend to have file/folder naming conventions that don't play nicely with telescope. I'll try to incorporate a fix for this into my PR and its subsequent PRs but can you dumb down your steps to reproduce? I've never used sveltekit so I tried replicating the bug by simply creating this file structure without using sveltekit and playing around in telescope and things appear to be working fine for me.
|
Thank you for the link to that other issue. I am experiencing it with a private work project. I will try to make a reproducible repo on windows when I get home. I can say that the issue does not happen with my exact same config when using ubuntu on wsl2. So it may be a windows specific issue. I will follow up tonight and link a reproducible repo on windows. |
I was able to reproduce the issue without using sveltekit or any javascript framework. On windows 11 I just made a directory that matched the Using netrw I navigated to the parent directory of the However if you navigate to the parent folder again i.e. At no point did the preview show the content, even when live grep and telescope navigated and opened the correct file. Please let me know if you were able to follow these instructions and reproduce. Again this is only on windows 11, and only when you are more than one directory above the |
Hmm.. navigating with |
After some more digging it looks to be a behavior similar to or exactly matching #1171 If anyone who is able to test on windows finds this, here is what happens:
So it must be something with how plenary or telescope handle that I also might be missing a config or setting on my end that could alleviate this. Any information would be appreciated. |
so i've tested this with a sveltekit repo from work an i only had issues previewing thanks :) |
so yeah it works on linux but there is still the posibility we have to escape on windows because windows |
I tested with the fix/windows_parentheses_escape and master branch and the issue did persist. I was unable to preview any files in any directory with the name including parentheses, and unable to open them directly from the telescope find_files. I use the same configs for my windows(work) computer and my personal(fedora) computer. The issue definitely does not persist on linux, so I agree that it is windows doing some sort of escaping. Would telescope need to escape the I don't know much about lua dev, but I am happy to test any theories. Or if there is any additional info that would help. Thanks, |
okay if thats an isolated windows issue i gonna setup a windows vm and test it there. that's probably easier. i am come back to you once i have a solution for that issues (in the next couple of days). thanks for reporting :) |
Small update. I did try using nvChad and Lunarvim to see if their pre-configuration worked. It did not. And the issue was happening with Nvim-tree, so I believe this is not something isolated to telescope but vim and neovim issues. |
I managed to get a neovim setup working on windows and there is definitely some strange behavior with the |
Thank you for following up. I have a feeling it is related to windows wrapping directory names with special characters in single quotes, and then the quote getting escaped when neovim is opening the directory/folder location. I can reliably reproduce and I am happy to do any testing that would be helpful. I just do not know enough about neovim's workings to try and diagnose. |
I have a fix for this. I have it working for opening files, but I am not sure exactly where the code is that provides a path for the previewer to view a file. Could you help me figure out where that is. Basically I have a piece of code that correctly escapes these characters for windows. I just need to modify the path it is passing into the previewer. |
That's good to hear. telescope.nvim/lua/telescope/previewers/buffer_previewer.lua Lines 482 to 508 in 2d92125
I think the |
Thank you. You are correct, the from entry looks like what I want. My changes so far fix file opening, and the preview works when moving down, but not up. |
I am experiencing something similar but with the nextjs dynamic routes convention of using square brackets in the folder names and also as #2446 (comment) says, similar to case #1171 but in windows and powershell I don't know if it helps but I found this post that explains the reason for this in powershell and an workaround for it, in commands it works for me like this: cd "./```[locale``]" This only happens with folders, in files with square brackets in the name ( |
Please, specify your operating system. There might be issues with path slash delimiters... |
I had the same problem as @davisthedev. I also use Windows 11 and when I tried to open files in a folder of a SvelteKit-Advanced-layout, Telescope failed. As described above, only the path require("telescope").setup({
pickers = {
find_files = {
hidden = true,
find_command = {
"rg",
"--files",
"--glob",
"!{.git/*,.svelte-kit/*,target/*,node_modules/*}",
"--path-separator",
"/",
},
},
},
}) @KevinSilvester has already suggested something similar here. Telescope now uses |
New solution based on: MagicDuck/grug-far.nvim#305 return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
config = function()
local telescope = require 'telescope'
local actions = require 'telescope.actions'
-- https://github.com/MagicDuck/grug-far.nvim/pull/305
local is_windows = vim.fn.has('win64') == 1 or vim.fn.has('win32') == 1
local vimfnameescape = vim.fn.fnameescape
local winfnameescape = function(path)
local escaped_path = vimfnameescape(path)
if is_windows then
local need_extra_esc = path:find('[%[%]`%$~]')
local esc = need_extra_esc and '\\\\' or '\\'
escaped_path = escaped_path:gsub('\\[%(%)%^&;]', esc .. '%1')
if need_extra_esc then
escaped_path = escaped_path:gsub("\\\\['` ]", '\\%1')
end
end
return escaped_path
end
local select_default = function(prompt_bufnr)
vim.fn.fnameescape = winfnameescape
local result = actions.select_default(prompt_bufnr, "default")
vim.fn.fnameescape = vimfnameescape
return result
end
telescope.setup {
defaults = {
mappings = {
i = {
['<cr>'] = select_default,
},
n = {
['<cr>'] = select_default,
}
},
},
}
end
} |
Thanks! Worked perfectly. |
Description
When using telescope search files or live grep within a sveltekit project telescope is unable to preview or open files contained within a sveltekit advanced layout group: sveltekit docs.
Neovim version
Operating system and version
Windows 11
Telescope version / branch / rev
telescope 0.1.1
checkhealth telescope
Steps to reproduce
Within a sveltekit project using the advanced routeing -> advanced layout -> (groups).
Open a search files or live grep telescope window and search for content that will be nested below the route like /routes/(group)/.
The preview window will not display any content.
Then use your bound key or to open the selected file.
The route will show as /routes(group)/ with the / preceding the group not displaying.
This will open a new buffer with no content.
Expected behavior
That telescope is able to parse, display preview, and open files contained within these routes.
Actual behavior
Telescope is unable to preview content and open files contained within these routes
Minimal config
Notes from @jamestrew (2024-03-23):
There's a workaround for
rg
using pickers (find_files
,live_grep
,grep_string
) hereStill affects many other file related pickers (
current_buffer_fuzzy_find
confirmed).The text was updated successfully, but these errors were encountered: