Improve .ini file formatting

End every file with a newline, and only display 1 empty line between each section, to improve readabillity.

fixes #8706
This commit is contained in:
Matthias Jentsch 2015-06-01 16:12:02 +02:00
parent 29cc92a3f3
commit 1901f0af98
2 changed files with 9 additions and 3 deletions

View File

@ -62,7 +62,7 @@ class IniEditor
$this->commentIndentation = array_key_exists('commentIndentation', $options) $this->commentIndentation = array_key_exists('commentIndentation', $options)
? $options['commentIndentation'] : 43; ? $options['commentIndentation'] : 43;
$this->sectionSeparators = array_key_exists('sectionSeparators', $options) $this->sectionSeparators = array_key_exists('sectionSeparators', $options)
? $options['sectionSeparators'] : 2; ? $options['sectionSeparators'] : 1;
} }
/** /**
@ -323,6 +323,12 @@ class IniEditor
private function cleanUpWhitespaces() private function cleanUpWhitespaces()
{ {
$i = count($this->text) - 1; $i = count($this->text) - 1;
// remove all trailing whitespaces
while ($i > 0 && preg_match('/^\s*$/', $this->text[$i]) === 1) {
$this->deleteLine($i);
$i--;
}
for (; $i > 0; $i--) { for (; $i > 0; $i--) {
$line = $this->text[$i]; $line = $this->text[$i];
if ($this->isSectionDeclaration($line) && $i > 0) { if ($this->isSectionDeclaration($line) && $i > 0) {
@ -351,6 +357,8 @@ class IniEditor
} }
} }
} }
// always end file with a linebreak
$this->insertAtLine(count($this->text) + 1, "");
} }
/** /**

View File

@ -106,8 +106,6 @@
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php
?>
<?php if ($unackCount > 0): ?> <?php if ($unackCount > 0): ?>
<br> <br>
<?= $this->qlink( <?= $this->qlink(