Skip to content

Commit a77e23b

Browse files
Fix API consistency in formatting verification methods
Make parameter types consistent across all three formatting methods: - VerifyFormatDocument() takes no marker parameter - VerifyFormatSelection() takes *RangeMarker (from f.Ranges()) - VerifyFormatOnType() takes string marker name Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
1 parent 6befa0b commit a77e23b

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

internal/fourslash/fourslash.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,25 +2252,17 @@ func (f *FourslashTest) VerifyFormatDocument(t *testing.T, options *lsproto.Form
22522252

22532253
// VerifyFormatSelection verifies formatting of a selected range.
22542254
// It sends a textDocument/rangeFormatting request and compares the result with a baseline.
2255-
func (f *FourslashTest) VerifyFormatSelection(t *testing.T, markerOrRange MarkerOrRange, options *lsproto.FormattingOptions) {
2255+
// rangeMarker should be obtained from f.Ranges()[index].
2256+
func (f *FourslashTest) VerifyFormatSelection(t *testing.T, rangeMarker *RangeMarker, options *lsproto.FormattingOptions) {
22562257
if options == nil {
22572258
options = &lsproto.FormattingOptions{
22582259
TabSize: 4,
22592260
InsertSpaces: true,
22602261
}
22612262
}
22622263

2263-
f.goToMarker(t, markerOrRange)
2264-
var formatRange lsproto.Range
2265-
if rangeMarker, ok := markerOrRange.(*RangeMarker); ok {
2266-
formatRange = rangeMarker.LSRange
2267-
} else {
2268-
// If it's just a marker position, format from that position to the end of the line
2269-
formatRange = lsproto.Range{
2270-
Start: f.currentCaretPosition,
2271-
End: f.currentCaretPosition,
2272-
}
2273-
}
2264+
f.goToMarker(t, rangeMarker)
2265+
formatRange := rangeMarker.LSRange
22742266

22752267
params := &lsproto.DocumentRangeFormattingParams{
22762268
TextDocument: lsproto.TextDocumentIdentifier{
@@ -2293,15 +2285,16 @@ func (f *FourslashTest) VerifyFormatSelection(t *testing.T, markerOrRange Marker
22932285

22942286
// VerifyFormatOnType verifies on-type formatting (e.g., after typing `;`, `}`, or newline).
22952287
// It sends a textDocument/onTypeFormatting request and compares the result with a baseline.
2296-
func (f *FourslashTest) VerifyFormatOnType(t *testing.T, marker string, character string, options *lsproto.FormattingOptions) {
2288+
// markerName should be the name of a marker in the test file (e.g., "a" for /*a*/).
2289+
func (f *FourslashTest) VerifyFormatOnType(t *testing.T, markerName string, character string, options *lsproto.FormattingOptions) {
22972290
if options == nil {
22982291
options = &lsproto.FormattingOptions{
22992292
TabSize: 4,
23002293
InsertSpaces: true,
23012294
}
23022295
}
23032296

2304-
f.GoToMarker(t, marker)
2297+
f.GoToMarker(t, markerName)
23052298

23062299
params := &lsproto.DocumentOnTypeFormattingParams{
23072300
TextDocument: lsproto.TextDocumentIdentifier{

0 commit comments

Comments
 (0)