diff --git a/src/formatter/header.ts b/src/formatter/header.ts index 303f7aed..2cb843ee 100644 --- a/src/formatter/header.ts +++ b/src/formatter/header.ts @@ -38,8 +38,10 @@ export function printHeader( } = parseResult; /* eslint-enable prefer-const */ + const multiline = type === 'multi-line' && (params.length > 0 || optionalParams.length > 0); + const result = new LineBuilder(indent); - if (type === 'multi-line') { + if (multiline) { result.firstLineIsPartial = false; } if (wrappingTag !== null) { @@ -60,7 +62,7 @@ export function printHeader( returnType === null ) { // do not print a parameter list - } else if (type === 'single-line') { + } else if (!multiline) { result.appendText(' ' + printSimpleParamList(params, optionalParams)); } else { result.appendText(' ('); @@ -80,7 +82,7 @@ export function printHeader( if (wrappingTag !== null) { result.appendText(``); } - if (type === 'multi-line') { + if (multiline) { result.linebreak(); } diff --git a/test/formatter.js b/test/formatter.js index 2f96b9ff..f232b4b4 100644 --- a/test/formatter.js +++ b/test/formatter.js @@ -609,6 +609,30 @@ describe('equation formatting', () => { }); describe('structured header formatting', () => { + it('multiline with no arguments', async () => { + await assertDocFormatsAs( + ` + +

+ Foo ( + ): ~empty~ +

+ +
+
+
+ `, + dedentKeepingTrailingNewline` + +

Foo ( ): ~empty~

+ +
+
+
+ `, + ); + }); + it('whitespace in inline style', async () => { await assertDocFormatsAs( `