diff --git a/tests/cases/fourslash/formattingOnChainedCallbacks.ts b/tests/cases/fourslash/formattingOnChainedCallbacks.ts index b8dbc55d8b6..5c1eafbbd24 100644 --- a/tests/cases/fourslash/formattingOnChainedCallbacks.ts +++ b/tests/cases/fourslash/formattingOnChainedCallbacks.ts @@ -20,6 +20,50 @@ //// /*n2*/ //// .then(); +// @Filename: listSmart.ts +////Promise +//// .resolve().then( +//// /*listSmart1*/ +//// 3, +//// /*listSmart2*/ +//// [ +//// 3 +//// /*listSmart3*/ +//// ] +//// /*listSmart4*/ +//// ); + +// @Filename: listZeroIndent.ts +////Promise.resolve([ +////]).then( +//// /*listZeroIndent1*/ +//// [ +//// /*listZeroIndent2*/ +//// 3 +//// ] +//// ); + +// @Filename: listTypeParameter1.ts +////foo.then +//// < +//// /*listTypeParameter1*/ +//// void +//// /*listTypeParameter2*/ +//// >( +//// function (): void { +//// }, +//// function (): void { +//// } +//// ); + +// @Filename: listComment.ts +////Promise +//// .then( +//// // euphonium +//// "k" +//// // oboe +//// ); + goTo.marker('1'); edit.insertLine(''); @@ -49,4 +93,68 @@ verify.currentLineContentIs(' });'); goTo.marker('n1'); verify.indentationIs(8); goTo.marker('n2'); -verify.indentationIs(4); \ No newline at end of file +verify.indentationIs(4); + +goTo.file(1); +format.document(); +verify.currentFileContentIs(`Promise + .resolve().then( + + 3, + + [ + 3 + + ] + + );`); +goTo.marker("listSmart1"); +verify.indentationIs(8); +goTo.marker("listSmart2"); +verify.indentationIs(8); +goTo.marker("listSmart3"); +verify.indentationIs(12); +goTo.marker("listSmart4"); +verify.indentationIs(8); + +goTo.file(2); +format.document(); +verify.currentFileContentIs(`Promise.resolve([ +]).then( + + [ + + 3 + ] +);`); +goTo.marker("listZeroIndent1"); +verify.indentationIs(4); +goTo.marker("listZeroIndent2"); +verify.indentationIs(8); + +goTo.file(3); +format.document(); +verify.currentFileContentIs(`foo.then + < + + void + + >( + function(): void { + }, + function(): void { + } + );`); +goTo.marker("listTypeParameter1"); +verify.indentationIs(8); +goTo.marker("listTypeParameter2"); +verify.indentationIs(8); + +goTo.file(4); +format.document(); +verify.currentFileContentIs(`Promise + .then( + // euphonium + "k" + // oboe + );`) diff --git a/tests/cases/fourslash/formattingOnTypeLiteral.ts b/tests/cases/fourslash/formattingOnTypeLiteral.ts new file mode 100644 index 00000000000..9b7929a5f5e --- /dev/null +++ b/tests/cases/fourslash/formattingOnTypeLiteral.ts @@ -0,0 +1,37 @@ +/// + +////function _uniteVertices

( +//// minority: Pinned>, +//// majorityCounter: number, +//// majority: Pinned> +////): { +//// /*start*/ +//// majorityCounter: number; +//// vertecis: Pinned; +//// }>; +//// /*end*/ +//// } { +////} + +format.document(); +verify.currentFileContentIs(`function _uniteVertices

( + minority: Pinned>, + majorityCounter: number, + majority: Pinned> +): { + + majorityCounter: number; + vertecis: Pinned; + }>; + +} { +}`); + +goTo.marker("start"); +verify.indentationIs(4); +goTo.marker("end"); +verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnListEnd.ts b/tests/cases/fourslash/smartIndentOnListEnd.ts new file mode 100644 index 00000000000..21c6653fa95 --- /dev/null +++ b/tests/cases/fourslash/smartIndentOnListEnd.ts @@ -0,0 +1,12 @@ +/// + +////var a = [] +/////*1*/ +////| {} +/////*2*/ +////| ""; + +goTo.marker("1"); +verify.indentationIs(4) +goTo.marker("2"); +verify.indentationIs(4) \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts index 73bd7d388c4..5e7e033850a 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -3,15 +3,18 @@ ////function f/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/ -function verifyIndentationAfterNewLine(marker: string, indentation: number): void { +function verifyIndentationAfterNewLine(marker: string, indentation: number, positionWorkaround: number, expectedText: string): void { goTo.marker(marker); edit.insert("\n"); + // The next two lines are to workaround #13433 + goTo.position(positionWorkaround); + verify.textAtCaretIs(expectedText); verify.indentationIs(indentation); } -verifyIndentationAfterNewLine("1", 4); -verifyIndentationAfterNewLine("2", 4); -verifyIndentationAfterNewLine("3", 4); -verifyIndentationAfterNewLine("4", 8); -verifyIndentationAfterNewLine("5", 4); -verifyIndentationAfterNewLine("6", 4); \ No newline at end of file +verifyIndentationAfterNewLine("1", 4, 24, '('); +verifyIndentationAfterNewLine("2", 8, 34, 'a'); +verifyIndentationAfterNewLine("3", 8, 48, 'b'); +verifyIndentationAfterNewLine("4", 12, 63, 'B'); +verifyIndentationAfterNewLine("5", 8, 76, ','); +verifyIndentationAfterNewLine("6", 8, 83, '');