diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index ad9b2f179a..d9a4ca8125 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -398,7 +398,6 @@ namespace ts.formatting { // formatting context is used by rules provider const formattingContext = new FormattingContext(sourceFile, requestKind, options); - let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; let previousRangeStartLine: number; @@ -883,7 +882,7 @@ namespace ts.formatting { const rangeHasError = rangeContainsError(range); let lineAdded: boolean; - if (!rangeHasError && !previousRangeHasError) { + if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line const originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); @@ -898,7 +897,6 @@ namespace ts.formatting { previousRange = range; previousParent = parent; previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; return lineAdded; } diff --git a/tests/cases/fourslash/formatEmptyParamList.ts b/tests/cases/fourslash/formatEmptyParamList.ts index 1822506d48..16a32abcf8 100644 --- a/tests/cases/fourslash/formatEmptyParamList.ts +++ b/tests/cases/fourslash/formatEmptyParamList.ts @@ -2,4 +2,4 @@ ////function f( f: function){/*1*/ goTo.marker("1"); edit.insert("}"); -verify.currentLineContentIs("function f(f: function) { }") +verify.currentLineContentIs("function f(f: function) { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatIfWithEmptyCondition.ts b/tests/cases/fourslash/formatIfWithEmptyCondition.ts new file mode 100644 index 0000000000..6e949900e2 --- /dev/null +++ b/tests/cases/fourslash/formatIfWithEmptyCondition.ts @@ -0,0 +1,11 @@ +/// + +//// if () { +//// } + +format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); +format.document(); +verify.currentFileContentIs( +`if () +{ +}`); diff --git a/tests/cases/fourslash/formattingOnConstructorSignature.ts b/tests/cases/fourslash/formattingOnConstructorSignature.ts index 6b91396e53..209527e825 100644 --- a/tests/cases/fourslash/formattingOnConstructorSignature.ts +++ b/tests/cases/fourslash/formattingOnConstructorSignature.ts @@ -4,6 +4,6 @@ /////*2*/type Stylet = { new () {} } format.document(); goTo.marker("1"); -verify.currentLineContentIs("interface Gourai { new() {} }"); +verify.currentLineContentIs("interface Gourai { new() { } }"); goTo.marker("2"); -verify.currentLineContentIs("type Stylet = { new() {} }"); \ No newline at end of file +verify.currentLineContentIs("type Stylet = { new() { } }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingSkippedTokens.ts b/tests/cases/fourslash/formattingSkippedTokens.ts index d3e76e9735..caf65d1dc2 100644 --- a/tests/cases/fourslash/formattingSkippedTokens.ts +++ b/tests/cases/fourslash/formattingSkippedTokens.ts @@ -14,7 +14,7 @@ verify.currentLineContentIs('foo(): Bar { }'); goTo.marker('2'); verify.currentLineContentIs('function Foo() # { }'); goTo.marker('3'); -verify.currentLineContentIs('4 +:5'); +verify.currentLineContentIs('4 +: 5'); goTo.marker('4'); verify.currentLineContentIs(' : T) { }'); goTo.marker('5'); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5175b52df6..78c62b71ea 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -336,7 +336,7 @@ declare namespace FourSlashInterface { setFormatOptions(options: FormatCodeOptions): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; - setOption(name: string, value: number | string | boolean): void; + setOption(name: keyof FormatCodeOptions, value: number | string | boolean): void; } class cancellation { resetCancelled(): void;