(indentation int, options lsutil.FormatCodeSettings)
| 986 | } |
| 987 | |
| 988 | func 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 | |
| 1007 | func createTextChangeFromStartLength(start int, length int, newText string) core.TextChange { |
| 1008 | return core.TextChange{ |
no test coverage detected