MCPcopy Create free account
hub / github.com/microsoft/typescript-go / ProvideFormatDocumentOnType

Method ProvideFormatDocumentOnType

internal/ls/format.go:65–85  ·  view source on GitHub ↗
(
	ctx context.Context,
	documentURI lsproto.DocumentUri,
	options *lsproto.FormattingOptions,
	position lsproto.Position,
	character string,
)

Source from the content-addressed store, hash-verified

63}
64
65func (l *LanguageService) ProvideFormatDocumentOnType(
66 ctx context.Context,
67 documentURI lsproto.DocumentUri,
68 options *lsproto.FormattingOptions,
69 position lsproto.Position,
70 character string,
71) (lsproto.DocumentOnTypeFormattingResponse, error) {
72 if l.UserPreferences().EnableFormatting.IsFalse() {
73 return lsproto.TextEditsOrNull{}, nil
74 }
75 _, file := l.getProgramAndFile(documentURI)
76 formatOpts := lsutil.FromLSFormatOptions(l.FormatOptions(), options)
77 edits := l.toLSProtoTextEdits(file, l.getFormattingEditsAfterKeystroke(
78 ctx,
79 file,
80 formatOpts,
81 int(l.converters.LineAndCharacterToPosition(file, position)),
82 character,
83 ))
84 return lsproto.TextEditsOrNull{TextEdits: &edits}, nil
85}
86
87func (l *LanguageService) getFormattingEditsForRange(
88 ctx context.Context,

Callers 1

Calls 9

UserPreferencesMethod · 0.95
getProgramAndFileMethod · 0.95
FormatOptionsMethod · 0.95
toLSProtoTextEditsMethod · 0.95
FromLSFormatOptionsFunction · 0.92
IsFalseMethod · 0.80
intInterface · 0.50

Tested by

no test coverage detected