fix (tags|btags): escape all special characters (#1806)
This commit is contained in:
@@ -431,10 +431,12 @@ files.tags = function(opts)
|
|||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
|
|
||||||
if selection.scode then
|
if selection.scode then
|
||||||
local scode = string.gsub(selection.scode, "[$]$", "")
|
-- un-escape / then escape required
|
||||||
scode = string.gsub(scode, [[\\]], [[\]])
|
-- special chars for vim.fn.search()
|
||||||
scode = string.gsub(scode, [[\/]], [[/]])
|
-- ] ~ *
|
||||||
scode = string.gsub(scode, "[*]", [[\*]])
|
local scode = selection.scode:gsub([[\/]], "/"):gsub("[%]~*]", function(x)
|
||||||
|
return "\\" .. x
|
||||||
|
end)
|
||||||
|
|
||||||
vim.cmd "norm! gg"
|
vim.cmd "norm! gg"
|
||||||
vim.fn.search(scode)
|
vim.fn.search(scode)
|
||||||
|
|||||||
@@ -484,10 +484,12 @@ previewers.ctags = defaulter(function(_)
|
|||||||
local determine_jump = function(entry)
|
local determine_jump = function(entry)
|
||||||
if entry.scode then
|
if entry.scode then
|
||||||
return function(self)
|
return function(self)
|
||||||
local scode = string.gsub(entry.scode, "[$]$", "")
|
-- un-escape / then escape required
|
||||||
scode = string.gsub(scode, [[\\]], [[\]])
|
-- special chars for vim.fn.search()
|
||||||
scode = string.gsub(scode, [[\/]], [[/]])
|
-- ] ~ *
|
||||||
scode = string.gsub(scode, "[*]", [[\*]])
|
local scode = entry.scode:gsub([[\/]], "/"):gsub("[%]~*]", function(x)
|
||||||
|
return "\\" .. x
|
||||||
|
end)
|
||||||
|
|
||||||
pcall(vim.fn.matchdelete, self.state.hl_id, self.state.winid)
|
pcall(vim.fn.matchdelete, self.state.hl_id, self.state.winid)
|
||||||
vim.cmd "norm! gg"
|
vim.cmd "norm! gg"
|
||||||
|
|||||||
Reference in New Issue
Block a user