1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 20:41:49 +03:00

simplify echo code, avoid trailing spaces

This commit is contained in:
Maxime Coste 2015-01-17 22:55:48 +00:00
parent 32319aca45
commit 7cdeb3d7f7
2 changed files with 3 additions and 5 deletions

View File

@ -780,9 +780,7 @@ const CommandDesc echo_cmd = {
CommandCompleter{},
[](const ParametersParser& parser, Context& context)
{
String message;
for (auto& param : parser)
message += param + " ";
String message = join(parser, ' ', false);
if (parser.has_option("debug"))
write_debug(message);
else

View File

@ -242,14 +242,14 @@ String escape(StringView str, StringView characters, char escape);
String unescape(StringView str, StringView characters, char escape);
template<typename Container>
String join(const Container& container, char joiner)
String join(const Container& container, char joiner, bool esc_joiner = true)
{
String res;
for (const auto& str : container)
{
if (not res.empty())
res += joiner;
res += escape(str, joiner, '\\');
res += esc_joiner ? escape(str, joiner, '\\') : str;
}
return res;
}