diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-02-23 15:45:51 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-02-24 13:41:47 -0300 |
commit | 0631e9642e7c8b615edb9bf31e3fcd95784b1eef (patch) | |
tree | a7b15ffc90c325b01a1a1e989858a63a767a2786 /generator.cpp | |
parent | 8c9f9660f04d1c5e462f6a815329bffa90327618 (diff) |
Empty lines from custom code must be cropped.
This is to avoid lines composed only of irritating trailing spaces.
Reviewed by Bruno Araújo <bruno.araujo@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator.cpp')
-rw-r--r-- | generator.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/generator.cpp b/generator.cpp index 376f56050..d1e89fd32 100644 --- a/generator.cpp +++ b/generator.cpp @@ -242,16 +242,22 @@ QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor) } } + static QRegExp emptyLine("\\s*[\\r]?[\\n]?\\s*"); + foreach(QString line, lst) { - while (line.end()->isSpace()) - line.chop(1); - int limit = 0; - for(int i = 0; i < spacesToRemove; ++i) { - if (!line[i].isSpace()) - break; - limit++; + if (!line.isEmpty() && !emptyLine.exactMatch(line)) { + while (line.end()->isSpace()) + line.chop(1); + int limit = 0; + for(int i = 0; i < spacesToRemove; ++i) { + if (!line[i].isSpace()) + break; + limit++; + } + + s << indentor << line.remove(0, limit); } - s << indentor << line.remove(0, limit) << endl; + s << endl; } return s; } |