From 118459db592ed2137e3f0cdde46933859baf9cf2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 12 Nov 2023 20:50:48 +0100 Subject: [PATCH] Quote completions of regex options Recent changes to `make_error_pattern` added a space to the default value. This means that set g make_error_pattern now produces an invalid command because regexes are not quoted. We do quote strings; regexes are not all that different so quote them too. --- src/regex.cc | 5 +++-- src/regex.hh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/regex.cc b/src/regex.cc index b80da6d4..df5af661 100644 --- a/src/regex.cc +++ b/src/regex.cc @@ -1,5 +1,6 @@ #include "regex.hh" #include "ranges.hh" +#include "string_utils.hh" namespace Kakoune { @@ -17,9 +18,9 @@ int Regex::named_capture_index(StringView name) const return it != m_impl->named_captures.end() ? it->index : -1; } -String option_to_string(const Regex& re) +String option_to_string(const Regex& re, Quoting quoting) { - return re.str(); + return option_to_string(re.str(), quoting); } Regex option_from_string(Meta::Type, StringView str) diff --git a/src/regex.hh b/src/regex.hh index a4d3d769..c0f3970e 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -162,7 +162,8 @@ bool backward_regex_search(It begin, It end, It subject_begin, It subject_end, return regex_search(begin, end, subject_begin, subject_end, res, re, flags, idle_func); } -String option_to_string(const Regex& re); +enum class Quoting; +String option_to_string(const Regex& re, Quoting quoting); Regex option_from_string(Meta::Type, StringView str); template