diff --git a/docs/Config.md b/docs/Config.md index 3dada749913..bafbbfc99b0 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -165,7 +165,7 @@ gui: showFileTree: true # If true, show the number of lines changed per file in the Files view - showNumberOfLineChanges: true + showNumberOfLineChangesFilesView: false # If true, show a random tip in the command log when Lazygit starts showRandomTip: true diff --git a/pkg/commands/git_commands/config.go b/pkg/commands/git_commands/config.go index da709254d89..9771f01d37a 100644 --- a/pkg/commands/git_commands/config.go +++ b/pkg/commands/git_commands/config.go @@ -111,7 +111,3 @@ func (self *ConfigCommands) GetCoreCommentChar() byte { func (self *ConfigCommands) GetRebaseUpdateRefs() bool { return self.gitConfig.GetBool("rebase.updateRefs") } - -func (cfgCommands *ConfigCommands) GetShowNumberOfLineChanges() bool { - return cfgCommands.UserConfig().Gui.ShowNumberOfLineChanges -} diff --git a/pkg/commands/git_commands/file_loader.go b/pkg/commands/git_commands/file_loader.go index e7c6aa454a4..38f55ca1dcc 100644 --- a/pkg/commands/git_commands/file_loader.go +++ b/pkg/commands/git_commands/file_loader.go @@ -12,7 +12,6 @@ import ( type FileLoaderConfig interface { GetShowUntrackedFiles() string - GetShowNumberOfLineChanges() bool } type FileLoader struct { @@ -52,7 +51,7 @@ func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File files := []*models.File{} fileDiffs := map[string]FileDiff{} - if self.config.GetShowNumberOfLineChanges() { + if self.GitCommon.Common.UserConfig().Gui.ShowNumberOfLineChangesFilesView { fileDiffs, err = self.getFileDiffs() if err != nil { self.Log.Error(err) diff --git a/pkg/commands/git_commands/file_loader_test.go b/pkg/commands/git_commands/file_loader_test.go index fe091bb8a4b..4d45633c9d9 100644 --- a/pkg/commands/git_commands/file_loader_test.go +++ b/pkg/commands/git_commands/file_loader_test.go @@ -11,11 +11,11 @@ import ( func TestFileGetStatusFiles(t *testing.T) { type scenario struct { - testName string - similarityThreshold int - runner oscommands.ICmdObjRunner - showNumberOfLineChanges bool - expectedFiles []*models.File + testName string + similarityThreshold int + runner oscommands.ICmdObjRunner + showNumberOfLineChangesFilesView bool + expectedFiles []*models.File } scenarios := []scenario{ @@ -38,7 +38,7 @@ func TestFileGetStatusFiles(t *testing.T) { "4\t1\tfile1.txt\x001\t0\tfile2.txt\x002\t2\tfile3.txt\x000\t2\tfile4.txt\x002\t2\tfile5.txt", nil, ), - showNumberOfLineChanges: true, + showNumberOfLineChangesFilesView: true, expectedFiles: []*models.File{ { Name: "file1.txt", @@ -201,10 +201,16 @@ func TestFileGetStatusFiles(t *testing.T) { appState := &config.AppState{} appState.RenameSimilarityThreshold = s.similarityThreshold + userConfig := &config.UserConfig{ + Gui: config.GuiConfig{ + ShowNumberOfLineChangesFilesView: s.showNumberOfLineChangesFilesView, + }, + } + loader := &FileLoader{ - GitCommon: buildGitCommon(commonDeps{appState: appState}), + GitCommon: buildGitCommon(commonDeps{appState: appState, userConfig: userConfig}), cmd: cmd, - config: &FakeFileLoaderConfig{showUntrackedFiles: "yes", showNumberOfLineChanges: s.showNumberOfLineChanges}, + config: &FakeFileLoaderConfig{showUntrackedFiles: "yes"}, getFileType: func(string) string { return "file" }, } @@ -214,14 +220,9 @@ func TestFileGetStatusFiles(t *testing.T) { } type FakeFileLoaderConfig struct { - showUntrackedFiles string - showNumberOfLineChanges bool + showUntrackedFiles string } func (self *FakeFileLoaderConfig) GetShowUntrackedFiles() string { return self.showUntrackedFiles } - -func (self *FakeFileLoaderConfig) GetShowNumberOfLineChanges() bool { - return self.showNumberOfLineChanges -} diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 46b4c45effe..9d92e2a3986 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -110,7 +110,7 @@ type GuiConfig struct { // This can be toggled from within Lazygit with the '~' key, but that will not change the default. ShowFileTree bool `yaml:"showFileTree"` // If true, show the number of lines changed per file in the Files view - ShowNumberOfLineChanges bool `yaml:"showNumberOfLineChanges"` + ShowNumberOfLineChangesFilesView bool `yaml:"showNumberOfLineChangesFilesView"` // If true, show a random tip in the command log when Lazygit starts ShowRandomTip bool `yaml:"showRandomTip"` // If true, show the command log @@ -707,31 +707,31 @@ func GetDefaultConfig() *UserConfig { UnstagedChangesColor: []string{"red"}, DefaultFgColor: []string{"default"}, }, - CommitLength: CommitLengthConfig{Show: true}, - SkipNoStagedFilesWarning: false, - ShowListFooter: true, - ShowCommandLog: true, - ShowBottomLine: true, - ShowPanelJumps: true, - ShowFileTree: true, - ShowNumberOfLineChanges: true, - ShowRandomTip: true, - ShowIcons: false, - NerdFontsVersion: "", - ShowFileIcons: true, - CommitAuthorShortLength: 2, - CommitAuthorLongLength: 17, - CommitHashLength: 8, - ShowBranchCommitHash: false, - ShowDivergenceFromBaseBranch: "none", - CommandLogSize: 8, - SplitDiff: "auto", - SkipRewordInEditorWarning: false, - WindowSize: "normal", - Border: "rounded", - AnimateExplosion: true, - PortraitMode: "auto", - FilterMode: "substring", + CommitLength: CommitLengthConfig{Show: true}, + SkipNoStagedFilesWarning: false, + ShowListFooter: true, + ShowCommandLog: true, + ShowBottomLine: true, + ShowPanelJumps: true, + ShowFileTree: true, + ShowNumberOfLineChangesFilesView: false, + ShowRandomTip: true, + ShowIcons: false, + NerdFontsVersion: "", + ShowFileIcons: true, + CommitAuthorShortLength: 2, + CommitAuthorLongLength: 17, + CommitHashLength: 8, + ShowBranchCommitHash: false, + ShowDivergenceFromBaseBranch: "none", + CommandLogSize: 8, + SplitDiff: "auto", + SkipRewordInEditorWarning: false, + WindowSize: "normal", + Border: "rounded", + AnimateExplosion: true, + PortraitMode: "auto", + FilterMode: "substring", Spinner: SpinnerConfig{ Frames: []string{"|", "/", "-", "\\"}, Rate: 50, diff --git a/pkg/gui/context/working_tree_context.go b/pkg/gui/context/working_tree_context.go index 381fb32193f..a0a4cf5dd0d 100644 --- a/pkg/gui/context/working_tree_context.go +++ b/pkg/gui/context/working_tree_context.go @@ -30,8 +30,8 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext { getDisplayStrings := func(_ int, _ int) [][]string { showFileIcons := icons.IsIconEnabled() && c.UserConfig().Gui.ShowFileIcons - showNumberOfLineChanges := c.UserConfig().Gui.ShowNumberOfLineChanges - lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons, showNumberOfLineChanges) + showNumberOfLineChangesFilesView := c.UserConfig().Gui.ShowNumberOfLineChangesFilesView + lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons, showNumberOfLineChangesFilesView) return lo.Map(lines, func(line string, _ int) []string { return []string{line} }) diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go index 16d46c24ff1..fb43de6ba3f 100644 --- a/pkg/gui/presentation/files.go +++ b/pkg/gui/presentation/files.go @@ -23,13 +23,13 @@ func RenderFileTree( tree filetree.IFileTree, submoduleConfigs []*models.SubmoduleConfig, showFileIcons, - showNumberOfLineChanges bool, + showNumberOfLineChangesFilesView bool, ) []string { collapsedPaths := tree.CollapsedPaths() return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string { fileNode := filetree.NewFileNode(node) - return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showNumberOfLineChanges, showFileIcons, submoduleConfigs, node) + return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showNumberOfLineChangesFilesView, showFileIcons, submoduleConfigs, node) }) } @@ -113,7 +113,7 @@ func getFileLine( hasStagedChanges bool, treeDepth int, visualDepth int, - showNumberOfLineChanges, + showNumberOfLineChangesFilesView, showFileIcons bool, submoduleConfigs []*models.SubmoduleConfig, node *filetree.Node[models.File], @@ -168,7 +168,7 @@ func getFileLine( output += theme.DefaultTextColor.Sprint(" (submodule)") } - if showNumberOfLineChanges { + if showNumberOfLineChangesFilesView { if lineChanges := formatLineChanges(file); lineChanges != "" { output += " " + lineChanges } diff --git a/schema/config.json b/schema/config.json index c3728bb7198..af26492183f 100644 --- a/schema/config.json +++ b/schema/config.json @@ -293,10 +293,10 @@ "description": "If true, display the files in the file views as a tree. If false, display the files as a flat list.\nThis can be toggled from within Lazygit with the '~' key, but that will not change the default.", "default": true }, - "showNumberOfLineChanges": { + "showNumberOfLineChangesFilesView": { "type": "boolean", "description": "If true, show the number of lines changed per file in the Files view", - "default": true + "default": false }, "showRandomTip": { "type": "boolean",