From d6e4990425633d3539ecbd9a13aac54ec680d65e Mon Sep 17 00:00:00 2001 From: Anderson Lizarazo Tellez <65132831+ALizarazoTellez@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:58:06 -0500 Subject: [PATCH] Escape parentheses from titles when searching for backlinks --- lua/telekasten.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index e5409f7..30d3dd9 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -1873,12 +1873,16 @@ local function ShowBacklinks(opts) local title = Pinfo:new({ filepath = vim.fn.expand("%:p"), M.Cfg }).title -- or vim.api.nvim_buf_get_name(0) + + local escaped_title = string.gsub(title, "%(", "\\(") + escaped_title = string.gsub(escaped_title, "%)", "\\)") + builtin.live_grep({ results_title = "Backlinks to " .. title, prompt_title = "Search", cwd = M.Cfg.home, search_dirs = { M.Cfg.home }, - default_text = "\\[\\[" .. title .. "([#|].+)?\\]\\]", + default_text = "\\[\\[" .. escaped_title .. "([#|].+)?\\]\\]", find_command = M.Cfg.find_command, attach_mappings = function(_, map) actions.select_default:replace(picker_actions.select_default)