diff options
| author | Cole Helbling <cole.e.helbling@outlook.com> | 2021-01-02 19:45:31 -0800 |
|---|---|---|
| committer | Cole Helbling <cole.e.helbling@outlook.com> | 2021-01-02 19:53:40 -0800 |
| commit | 7cde14680750ac71a9f127e2370bac3ad263e1e1 (patch) | |
| tree | 975dea9080242783a785dcb1868d028e20435d95 | |
| parent | 958a9431214dc4bece30aa30a8159e0bb8b5bbe7 (diff) | |
command_manager: only remove last eol in %sh{} expansions
This makes it possible to keep significant EOL in shell expansions (e.g.
for use with clipboard helpers).
| -rw-r--r-- | src/command_manager.cc | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index ca619f7f..82f4425a 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -323,14 +323,9 @@ expand_token(const Token& token, const Context& context, const ShellContext& she content, context, {}, ShellManager::Flags::WaitForStdout, shell_context).first; - int trailing_eol_count = 0; - for (auto c : str | reverse()) - { - if (c != '\n') - break; - ++trailing_eol_count; - } - str.resize(str.length() - trailing_eol_count, 0); + if (str.back() == '\n') + str.resize(str.length() - 1, 0); + return {str}; } case Token::Type::RegisterExpand: |
