diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index 17aca5e385c..4335e5ebfe1 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -195,20 +195,21 @@ func getHeader(binding *types.Binding, tr *i18n.TranslationSet) header { } func formatSections(tr *i18n.TranslationSet, bindingSections []*bindingSection) string { - content := fmt.Sprintf("# Lazygit %s\n", tr.Keybindings) + var content strings.Builder + content.WriteString(fmt.Sprintf("# Lazygit %s\n", tr.Keybindings)) - content += fmt.Sprintf("\n%s\n", italicize(tr.KeybindingsLegend)) + content.WriteString(fmt.Sprintf("\n%s\n", italicize(tr.KeybindingsLegend))) for _, section := range bindingSections { - content += formatTitle(section.title) - content += "| Key | Action | Info |\n" - content += "|-----|--------|-------------|\n" + content.WriteString(formatTitle(section.title)) + content.WriteString("| Key | Action | Info |\n") + content.WriteString("|-----|--------|-------------|\n") for _, binding := range section.bindings { - content += formatBinding(binding) + content.WriteString(formatBinding(binding)) } } - return content + return content.String() } func formatTitle(title string) string { diff --git a/pkg/commands/patch/patch_builder.go b/pkg/commands/patch/patch_builder.go index 466b3da097f..db834ba168f 100644 --- a/pkg/commands/patch/patch_builder.go +++ b/pkg/commands/patch/patch_builder.go @@ -66,22 +66,22 @@ func (p *PatchBuilder) Start(from, to string, reverse bool, canRebase bool) { } func (p *PatchBuilder) PatchToApply(reverse bool, turnAddedFilesIntoDiffAgainstEmptyFile bool) string { - patch := "" + var patch strings.Builder for filename, info := range p.fileInfoMap { if info.mode == UNSELECTED { continue } - patch += p.RenderPatchForFile(RenderPatchForFileOpts{ + patch.WriteString(p.RenderPatchForFile(RenderPatchForFileOpts{ Filename: filename, Plain: true, Reverse: reverse, TurnAddedFilesIntoDiffAgainstEmptyFile: turnAddedFilesIntoDiffAgainstEmptyFile, - }) + })) } - return patch + return patch.String() } func (p *PatchBuilder) addFileWhole(info *fileInfo) { diff --git a/pkg/gui/presentation/submodules.go b/pkg/gui/presentation/submodules.go index 72c6bfc081a..c7b51c6d893 100644 --- a/pkg/gui/presentation/submodules.go +++ b/pkg/gui/presentation/submodules.go @@ -1,6 +1,8 @@ package presentation import ( + "strings" + "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/samber/lo" @@ -15,11 +17,11 @@ func GetSubmoduleListDisplayStrings(submodules []*models.SubmoduleConfig) [][]st func getSubmoduleDisplayStrings(s *models.SubmoduleConfig) []string { name := s.Name if s.ParentModule != nil { - indentation := "" + count := 0 for p := s.ParentModule; p != nil; p = p.ParentModule { - indentation += " " + count++ } - + indentation := strings.Repeat(" ", count) name = indentation + "- " + s.Name }