summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-08-28 18:52:29 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-08-28 18:52:29 +0100
commit3150fe97cfc2f94768456faa361d89fabe4f33e3 (patch)
tree0a45db5682bb3ffa3019eff17f0ac2da17047ead /src
parent535a454349f4aa647644d8eef99c517c15ddbec8 (diff)
selections env var is : separated, and : in selections are escaped
Diffstat (limited to 'src')
-rw-r--r--src/main.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc
index 536ca157..d068e986 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -70,10 +70,17 @@ void register_env_vars()
{ const Range& sel = context.editor().main_selection();
return content(context.buffer(), sel); });
shell_manager.register_env_var("selections",
- [](const String& name, const Context& context)
- { auto sels = context.editor().selections_content();
- return std::accumulate(sels.begin(), sels.end(), ""_str,
- [](const String& lhs, const String& rhs) { return lhs.empty() ? rhs : lhs + "," + rhs; }); });
+ [](const String& name, const Context& context) {
+ auto sels = context.editor().selections_content();
+ String res;
+ for (size_t i = 0; i < sels.size(); ++i)
+ {
+ res += escape(sels[i], ':', '\\');
+ if (i != sels.size() - 1)
+ res += ':';
+ }
+ return res;
+ });
shell_manager.register_env_var("runtime",
[](const String& name, const Context& context)
{ return runtime_directory(); });