forked from qt-creator/qt-creator
QmDesigner: Add flag for adding lineSep to handle empty case
If line is empty and the continue path is taken result stays empty. This means we do net add the lineSep for the next line. Handling this explicitly with a flag fixes the issue. Change-Id: I879e6e4a7238069ecc63e8188f0fb5929ac05363 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -93,13 +93,17 @@ QString QMLRewriter::addIndentation(const QString &text, unsigned depth)
|
||||
|
||||
TextEditor::TabSettings tabSettings = textModifier()->tabSettings();
|
||||
QString result;
|
||||
bool addLineSep = false;
|
||||
constexpr char lineSep('\n');
|
||||
const QStringList lines = text.split(lineSep);
|
||||
for (const QString &line : lines) {
|
||||
if (!result.isEmpty())
|
||||
if (addLineSep)
|
||||
result += lineSep;
|
||||
|
||||
addLineSep = true;
|
||||
if (line.isEmpty())
|
||||
continue;
|
||||
|
||||
const int firstNoneSpace = TextEditor::TabSettings::firstNonSpace(line);
|
||||
const int lineIndentColumn = tabSettings.indentationColumn(line) + int(depth);
|
||||
result.append(tabSettings.indentationString(0, lineIndentColumn, 0));
|
||||
|
Reference in New Issue
Block a user