From 34bf85d8d17b868c8ecf7b71ae6a6411fcc347db Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Wed, 13 Mar 2013 12:37:24 +0100 Subject: [PATCH] Remove whitespace when shifting text left Previously shifting text left/right would ignore blank lines (as noted in issue #419). When shifting left though it does make sense to delete whitespace, especially as the same code is used to re-indent when pasting. Fixes #810. --- Frameworks/editor/src/transform.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Frameworks/editor/src/transform.cc b/Frameworks/editor/src/transform.cc index d2a99e71..b58e6cbb 100644 --- a/Frameworks/editor/src/transform.cc +++ b/Frameworks/editor/src/transform.cc @@ -116,17 +116,14 @@ namespace transform char const* from = it->first; char const* to = it->second; - if(!text::is_blank(from, to)) + if(amount > 0 && !text::is_blank(from, to)) { - if(amount > 0) - { - res += indent::create(amount, indent.tab_size(), indent.soft_tabs()); - } - else if(amount < 0) - { - for(int col = 0; from != to && col < -amount && text::is_space(*from); ++from) - col += *from == '\t' ? indent.tab_size() - (col % indent.tab_size()) : 1; - } + res += indent::create(amount, indent.tab_size(), indent.soft_tabs()); + } + else if(amount < 0) + { + for(int col = 0; from != to && col < -amount && text::is_space(*from); ++from) + col += *from == '\t' ? indent.tab_size() - (col % indent.tab_size()) : 1; } std::copy(from, to, back_inserter(res));