You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The appropriate indentation for a node is not necessarily the amount of leading whitespace on the line where the node starts, as this code naïvely assumes:
function getIndent(node) {
// TODO Improve this.
return lines.getIndentAt(node.loc.start.line);
}
The correct indentation for a node is something closer to the amount of leading whitespace on the line where the nearest Statement ancestor of the node begins.
The text was updated successfully, but these errors were encountered:
In order to reprint a node that originally appeared at a different
level of indentation, the patcher needs to de-indent the original
lines by their original indentation amount, then re-indent them by the
desired amount.
The previous heuristic for determining the original indentation amount
was easily fooled, but I put up with it because in practice it was
wrong rarely enough.
Here's an example of when it would be wrong:
function foo(bar,
baz) {
qux();
}
The previous version of getIndent reported the indentation of the
BlockStatement beginning at the "{" as being equal to the identation
of the "baz" token, when really it should be equal to the indentation
of the "function" keyword.
The new strategy is to find the starting column of the first ancestor
node on a line with nothing before it but whitespace.
Closes#6.
The appropriate indentation for a node is not necessarily the amount of leading whitespace on the line where the node starts, as this code naïvely assumes:
The correct indentation for a node is something closer to the amount of leading whitespace on the line where the nearest
Statement
ancestor of the node begins.The text was updated successfully, but these errors were encountered: