1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 04:24:48 +03:00

Escape the backslash chars as well when joining strings

Fixes #1014
This commit is contained in:
Maxime Coste 2016-12-17 05:48:42 +00:00
parent dc84cdd538
commit 2bdd361948
4 changed files with 7 additions and 1 deletions

View File

@ -330,12 +330,13 @@ String replace(StringView str, StringView substr, StringView replacement);
template<typename Container>
String join(const Container& container, char joiner, bool esc_joiner = true)
{
const char to_escape[] = { joiner, '\\' };
String res;
for (const auto& str : container)
{
if (not res.empty())
res += joiner;
res += esc_joiner ? escape(str, joiner, '\\') : str;
res += esc_joiner ? escape(str, to_escape, '\\') : str;
}
return res;
}

View File

@ -0,0 +1 @@
%<a-s>H

View File

@ -0,0 +1,3 @@
foo\:bar
foo\\
bar

View File

@ -0,0 +1 @@
foo\\\:bar:foo\\\\:bar