Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/format/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ func (w *formatSpanWorker) applyRuleEdits(rule *ruleImpl, previousRange TextRang
return LineActionLineAdded
}
case ruleActionInsertSpace:
// exit early if we on different lines and rule cannot change number of newlines
if rule.Flags() != ruleFlagsCanDeleteNewLines && previousStartLine != currentStartLine {
// exit early if EOF or on different lines and rule cannot change number of newlines
if currentRange.Kind == ast.KindEndOfFile || (rule.Flags() != ruleFlagsCanDeleteNewLines && previousStartLine != currentStartLine) {
return LineActionNone
}

Expand Down
40 changes: 0 additions & 40 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,73 +197,38 @@ TestExportEqualTypes
TestFindAllRefs_importType_js1
TestFindAllRefs_importType_js2
TestFindAllRefs_importType_js3
TestForceIndentAfterNewLineInsert
TestFormat01
TestFormatAfterObjectLiteral
TestFormatAsyncClassMethod1
TestFormatAsyncClassMethod2
TestFormatColonAndQMark
TestFormatConflictDiff3Marker1
TestFormatConflictMarker1
TestFormatDebuggerStatement
TestFormatDocumentPreserveTrailingWhitespace
TestFormatDocumentWithJSDoc
TestFormatDotAfterNumber
TestFormatEmptyParamList
TestFormatIfTryCatchBlocks
TestFormatIfWithEmptyCondition
TestFormatImplicitModule
TestFormatMultipleFunctionArguments
TestFormatNoSpaceAfterTemplateHeadAndMiddle
TestFormatOnSemiColonAfterBreak
TestFormatRemoveNewLineAfterOpenBrace
TestFormatSelectionJsxWithBinaryExpression
TestFormatSelectionPreserveTrailingWhitespace
TestFormatSelectionWithTrivia
TestFormatSimulatingScriptBlocks
TestFormatSpaceAfterImplementsExtends
TestFormatSpaceAfterTemplateHeadAndMiddle
TestFormatSpaceBetweenFunctionAndArrayIndex
TestFormattingAwait
TestFormattingChainingMethods
TestFormattingDecorators
TestFormattingDoubleLessThan
TestFormattingForIn
TestFormattingForLoopSemicolons
TestFormattingForOfKeyword
TestFormattingInExpressionsInTsx
TestFormattingJsxTexts3
TestFormattingJsxTexts4
TestFormattingNestedScopes
TestFormattingNonNullAssertionOperator
TestFormattingObjectLiteralOpenCurlyNewline
TestFormattingObjectLiteralOpenCurlyNewlineAssignment
TestFormattingObjectLiteralOpenCurlyNewlineTyping
TestFormattingObjectLiteralOpenCurlySingleLine
TestFormattingOfExportDefault
TestFormattingOnClasses
TestFormattingOnClosingBracket
TestFormattingOnDoWhileNoSemicolon
TestFormattingOnEmptyInterfaceLiteral
TestFormattingOnInvalidCodes
TestFormattingOnModuleIndentation
TestFormattingOnNestedDoWhileByEnter
TestFormattingOnNestedStatements
TestFormattingOnObjectLiteral
TestFormattingOnSingleLineBlocks
TestFormattingOnTabAfterCloseCurly
TestFormattingOnVariety
TestFormattingSpaceBeforeFunctionParen
TestFormattingSpaceBetweenParent
TestFormattingSpacesAfterConstructor
TestFormattingVoid
TestFormatTrimRemainingRange
TestFormatTryFinally
TestFormatTsxClosingAfterJsxText
TestFormatV8Directive
TestFormatWithStatement
TestFunctionIndentation
TestFunctionTypePredicateFormatting
TestFunduleWithRecursiveReference
TestGenericCombinators3
TestGenericCombinatorWithConstraints1
Expand Down Expand Up @@ -345,7 +310,6 @@ TestImportTypeCompletions6
TestImportTypeCompletions7
TestImportTypeCompletions8
TestImportTypeCompletions9
TestIndentationInJsx3
TestIndexerReturnTypes1
TestIndirectClassInstantiation
TestInstanceTypesForGenericType1
Expand Down Expand Up @@ -397,14 +361,12 @@ TestLocalFunction
TestMemberListInReopenedEnum
TestMemberListInWithBlock
TestMemberListOfExportedClass
TestMultilineCommentBeforeOpenBrace
TestMultiModuleFundule
TestNgProxy1
TestNgProxy4
TestNoQuickInfoForLabel
TestNoQuickInfoInWhitespace
TestNumericPropertyNames
TestOptionalPropertyFormatting
TestOverloadQuickInfo
TestParameterWithDestructuring
TestParameterWithNestedDestructuring
Expand Down Expand Up @@ -544,5 +506,3 @@ TestTsxQuickInfo6
TestTsxQuickInfo7
TestTypeCheckAfterResolve
TestTypeOperatorNodeBuilding
TestUnclosedStringLiteralAutoformating
TestWhiteSpaceTrimming
3 changes: 3 additions & 0 deletions internal/fourslash/fourslash.go
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,9 @@ func (f *FourslashTest) getSelection() core.TextRange {

// Updates f.currentCaretPosition
func (f *FourslashTest) applyTextEdits(t *testing.T, edits []*lsproto.TextEdit) int {
if len(edits) == 0 {
return 0
}
script := f.getScriptInfo(f.activeFilename)
slices.SortFunc(edits, func(a, b *lsproto.TextEdit) int {
aStart := f.converters.LineAndCharacterToPosition(script, a.Range.Start)
Expand Down
2 changes: 1 addition & 1 deletion internal/fourslash/tests/formatDocumentZeroTabSize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ func TestFormatDocumentZeroTabSize(t *testing.T) {
opts.FormatCodeSettings.ConvertTabsToSpaces = true
f.Configure(t, opts)
f.FormatDocument(t, "")
f.VerifyCurrentFileContent(t, "function foo() {\nif (true) {\nvar x = 1;\n}\n} ")
f.VerifyCurrentFileContent(t, "function foo() {\nif (true) {\nvar x = 1;\n}\n}")
}