Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 5 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: 3 additions & 1 deletion internal/format/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,9 @@ func (w *formatSpanWorker) trimTrailingWhitespacesForRemainingRange(trivias []Te
w.trimTrailingWitespacesForPositions(startPos, trivia.Loc.Pos()-1, w.previousRange)
}

startPos = trivia.Loc.End() + 1
if trivia.Loc.End()+1 > startPos {
startPos = trivia.Loc.End() + 1
}
}
}

Expand Down
26 changes: 26 additions & 0 deletions internal/fourslash/tests/formatWhitespaceBetweenComments_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestFormatWhitespaceBetweenComments(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = ` const x = "wont format"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I prefer when the contents start on the next line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved content to start on next line in d90bcc77.

//

//
`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.FormatDocument(t, "")
f.VerifyCurrentFileContent(t, `const x = "wont format"
//

//
`)
}
Loading