Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
don't render line break at the start of pretty output
Browse files Browse the repository at this point in the history
Summary:
jsbeautify always started with an extra linebreak, which was annoying

Reviewed By: epriestley

Test Plan: make

Revert Plan: ok
  • Loading branch information
Marcel Laverdet committed Jul 10, 2009
1 parent 24588c9 commit 8d859f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ rope_t Node::renderIndentedStatement(render_guts_t* guts, int indentation) const
if (guts->sanelineno) {
newline = this->renderLinenoCatchup(guts, ret);
} else {
ret += "\n";
newline = true;
if (guts->lineno == 2) {
ret += "\n";
newline = true;
} else {
// Use lineno property to keep track of whether or not we're on the first line,
// to avoid an extra line break at the beginning of the render.
guts->lineno = 2;
}
}
if (guts->pretty && newline) {
for (int i = 0; i < indentation; ++i) {
Expand Down Expand Up @@ -174,7 +180,7 @@ bool Node::renderLinenoCatchup(render_guts_t* guts, rope_t &rope) const {
return true;
}

unsigned int Node::lineno() const {
unsigned int Node::lineno() const {
return this->_lineno;
}

Expand Down

0 comments on commit 8d859f5

Please sign in to comment.