From 6bd8921119883d220524c91a819d9fbaf5fefa13 Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Fri, 17 Jun 2022 21:37:20 +0800 Subject: [PATCH] fix(cmd): escape double quote characters in a tip --- src/shell/scripts/omp.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shell/scripts/omp.lua b/src/shell/scripts/omp.lua index e6a4444c..15ed6787 100644 --- a/src/shell/scripts/omp.lua +++ b/src/shell/scripts/omp.lua @@ -106,6 +106,13 @@ local function get_posh_prompt(rprompt) end local function set_posh_tooltip(command) + if command == nil then + return + end + -- escape double quote characters properly, if any + command = string.gsub(command, '\\+"', '%1%1"') + command = string.gsub(command, '\\+$', '%1%1') + command = string.gsub(command, '"', '\\"') local prompt_exe = string.format('%s print tooltip --shell=cmd --config=%s --command="%s"', omp_exe(), omp_config(), command) local tooltip = run_posh_command(prompt_exe) if tooltip ~= "" then