Skip to content

Commit

Permalink
Support for empty lines in AA
Browse files Browse the repository at this point in the history
  • Loading branch information
fumer-fubotv committed May 9, 2024
1 parent 0ed0e98 commit 9be551d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Formatter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('Formatter', () => {
`);
});

it.only('empty newlines in AA do not break indentation', ()=>{
it('empty newlines in AA do not break indentation', ()=>{

Check failure on line 255 in src/Formatter.spec.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Missing space before =>

Check failure on line 255 in src/Formatter.spec.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Missing space after =>

Check failure on line 255 in src/Formatter.spec.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Missing space before =>

Check failure on line 255 in src/Formatter.spec.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Missing space after =>
formatEqual(undent`
sub test()
array = [{
Expand Down
4 changes: 4 additions & 0 deletions src/formatters/IndentFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ export class IndentFormatter {

for (let lineIndex = curLineLastToken.range.start.line; lineIndex >= 0; lineIndex--) {
let lineToken = lines[lineIndex];

if (lineToken.length === 1 && lineToken[0].kind === TokenKind.Newline) {
continue;
}
isWhiteSpaceToken = (lineToken[0].kind === TokenKind.Whitespace) || (lineToken[0].kind === TokenKind.Newline);
let firstToken = isWhiteSpaceToken ? util.getNextNonWhitespaceToken(lineToken, 0) : lineToken[0];
let lineStartPosition = firstToken ? firstToken.range.start.character : 0;
Expand Down

0 comments on commit 9be551d

Please sign in to comment.