MCPcopy
hub / github.com/jesseduffield/lazygit / WithPadding

Function WithPadding

pkg/utils/formatting.go:38–49  ·  view source on GitHub ↗

WithPadding pads a string as much as you want

(str string, padding int, alignment Alignment)

Source from the content-addressed store, hash-verified

36
37// WithPadding pads a string as much as you want
38func WithPadding(str string, padding int, alignment Alignment) string {
39 uncoloredStr := Decolorise(str)
40 width := StringWidth(uncoloredStr)
41 if padding < width {
42 return str
43 }
44 space := strings.Repeat(" ", padding-width)
45 if alignment == AlignLeft {
46 return str + space
47 }
48 return space + str
49}
50
51// defaults to left-aligning each column. If you want to set the alignment of
52// each column, pass in a slice of Alignment values.

Callers 3

LongAuthorFunction · 0.92
getPaddedDisplayStringsFunction · 0.85
TestWithPaddingFunction · 0.85

Calls 2

DecoloriseFunction · 0.85
StringWidthFunction · 0.85

Tested by 1

TestWithPaddingFunction · 0.68