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
help_tags() does not escape special characters #3027
Comments
And in telescope.nvim/lua/telescope/builtin/__internal.lua Lines 778 to 784 in 1bb28df
|
I think this might work for all characters, although I couldn't test it for non-ascii: local lang = 'en'
local subject= '[==]'
local code_points = vim.fn.str2list(subject)
local escaped_str = '\\v'
for _, code in ipairs(code_points) do
escaped_str = escaped_str .. '%U' .. string.format('%x', code)
end
escaped_str = escaped_str .. '@' .. lang
vim.cmd.help(escaped_str) |
Oof, I'm almost tempted to say "it's not our problem" considering Your solution is pretty interesting though - first time actually learning about all this "magic". |
I tested it and it works for multibyte characters. I also wrote a test to see which other help tags are affected:
How to test: # move tags file from neovim's runtime/doc/tags to current directory
nvim --clean -u tags-test.lua tags-test.lua-- quite slow!
local function goto_fixed(tag)
local lang = 'en'
local code_points = vim.fn.str2list(tag)
local escaped_str = '\\v'
for _, code in ipairs(code_points) do
escaped_str = escaped_str .. '%U' .. string.format('%x', code)
end
escaped_str = escaped_str .. '@' .. lang
vim.cmd.help(escaped_str)
end
local function goto_orig(tag)
vim.cmd.help(tag .. '@en')
end
local function get_pos()
local name = vim.fn.expand('%:t')
local lnum = vim.fn.line('.')
return name .. ':' .. lnum
end
vim.cmd('syntax off')
vim.cmd('set syntax=off')
local count = 0
local lines = vim.fn.readfile('tags')
Result = {}
for i, line in ipairs(lines) do
local tag, file, _ = unpack(vim.split(line, '\t'))
goto_fixed(tag)
local fixed_pos = get_pos()
goto_orig(tag)
local orig_pos = get_pos()
if fixed_pos ~= orig_pos then
table.insert(Result, i..' '..tag..' '..file)
table.insert(Result, fixed_pos)
table.insert(Result, orig_pos)
table.insert(Result, '')
end
::next::
count = count + 1
if count == 100 then
print(i, 'of', #lines)
vim.cmd('redraw!')
count = 0
end
end
vim.cmd('close')
print('Done')
vim.api.nvim_buf_set_lines(0, 0, 0, false, Result) |
Description
using Telescope
help_tags
to jump to[==]
(equivalence class) opens help for=
instead.Neovim version
Operating system and version
Windows 10
Telescope version / branch / rev
1bb28df
checkhealth telescope
Steps to reproduce
nvim -nu minimal.lua
:Telescope help_tags<CR>
[==]<CR>
Expected behavior
help_tags
opens help for [==] (in runtime/doc/pattern.txt),the same file that is displayed in the preview.
Actual behavior
Help is opened for = (in runtime/doc/change.txt)
Minimal config
The text was updated successfully, but these errors were encountered: