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.
This commit is contained in:
Allan Odgaard
2013-03-13 12:37:24 +01:00
parent 0075b46c82
commit 34bf85d8d1

View File

@@ -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));