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

Function getIndentationString

internal/format/span.go:988–1005  ·  view source on GitHub ↗
(indentation int, options lsutil.FormatCodeSettings)

Source from the content-addressed store, hash-verified

986}
987
988func getIndentationString(indentation int, options lsutil.FormatCodeSettings) string {
989 // go's `strings.Repeat` already has static, global caching for repeated tabs and spaces, so there's no need to cache here like in strada
990 if !options.ConvertTabsToSpaces.IsTrue() {
991 if options.TabSize == 0 {
992 return ""
993 }
994 tabs := int(math.Floor(float64(indentation) / float64(options.TabSize)))
995 spaces := indentation - (tabs * options.TabSize)
996 res := strings.Repeat("\t", tabs)
997 if spaces > 0 {
998 res = res + strings.Repeat(" ", spaces)
999 }
1000
1001 return res
1002 } else {
1003 return strings.Repeat(" ", indentation)
1004 }
1005}
1006
1007func createTextChangeFromStartLength(start int, length int, newText string) core.TextChange {
1008 return core.TextChange{

Callers 2

insertIndentationMethod · 0.85

Calls 3

IsTrueMethod · 0.80
FloorMethod · 0.80
intInterface · 0.50

Tested by

no test coverage detected