summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2023-11-12 20:50:48 +0100
committerJohannes Altmanninger <aclopte@gmail.com>2023-11-13 23:42:39 +0100
commit118459db592ed2137e3f0cdde46933859baf9cf2 (patch)
treec96b775783fcd320ac0de16375dea4723ace8e62 /src
parented1e2f2e081b8391da8ecaa0c0481e693443058b (diff)
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 <tab> now produces an invalid command because regexes are not quoted. We do quote strings; regexes are not all that different so quote them too.
Diffstat (limited to 'src')
-rw-r--r--src/regex.cc5
-rw-r--r--src/regex.hh3
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<Regex>, 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<It, RegexMode::Backward>(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<Regex>, StringView str);
template<typename Iterator, RegexMode mode = RegexMode::Forward,