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

Function GetNewLineOrDefaultFromContext

internal/format/api.go:46–56  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

44}
45
46func GetNewLineOrDefaultFromContext(ctx context.Context) string { // TODO: Move into broader LS - more than just the formatter uses the newline editor setting/host new line
47 opt := GetFormatCodeSettingsFromContext(ctx)
48 if len(opt.NewLineCharacter) > 0 {
49 return opt.NewLineCharacter
50 }
51 host := ctx.Value(formatNewlineKey).(string)
52 if len(host) > 0 {
53 return host
54 }
55 return "\n"
56}
57
58func FormatSpan(ctx context.Context, span core.TextRange, file *ast.SourceFile, kind FormatRequestKind) []core.TextChange {
59 // find the smallest node that fully wraps the range and compute the initial indentation for the node

Callers 1

applyRuleEditsMethod · 0.85

Calls 3

lenFunction · 0.85
ValueMethod · 0.65

Tested by

no test coverage detected