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

Function GuessIndentation

internal/stringutil/util.go:124–150  ·  view source on GitHub ↗
(lines []string)

Source from the content-addressed store, hash-verified

122}
123
124func GuessIndentation(lines []string) int {
125 const MAX_SMI_X86 int = 0x3fff_ffff
126 indentation := MAX_SMI_X86
127 for _, line := range lines {
128 if len(line) == 0 {
129 continue
130 }
131 i := 0
132 for i < len(line) && i < indentation {
133 ch, size := utf8.DecodeRuneInString(line[i:])
134 if !IsWhiteSpaceLike(ch) {
135 break
136 }
137 i += size
138 }
139 if i < indentation {
140 indentation = i
141 }
142 if indentation == 0 {
143 return 0
144 }
145 }
146 if indentation == MAX_SMI_X86 {
147 return 0
148 }
149 return indentation
150}
151
152// https://tc39.es/ecma262/multipage/global-object.html#sec-encodeuri-uri
153func EncodeURI(s string) string {

Callers 2

writeLinesMethod · 0.92
DedentFunction · 0.92

Calls 2

lenFunction · 0.85
IsWhiteSpaceLikeFunction · 0.85

Tested by

no test coverage detected