Skip to content

Commit

Permalink
Rename feature in config and default to false
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaschwarz committed Nov 14, 2024
1 parent 222f9a4 commit 913d026
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 50 deletions.
2 changes: 1 addition & 1 deletion docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pkg/commands/git_commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions pkg/commands/git_commands/file_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

type FileLoaderConfig interface {
GetShowUntrackedFiles() string
GetShowNumberOfLineChanges() bool
}

type FileLoader struct {
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 15 additions & 14 deletions pkg/commands/git_commands/file_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
Expand Down Expand Up @@ -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" },
}

Expand All @@ -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
}
52 changes: 26 additions & 26 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/context/working_tree_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {

getDisplayStrings := func(_ int, _ int) [][]string {
showFileIcons := icons.IsIconEnabled() && c.UserConfig().Gui.ShowFileIcons
showNumberOfLineChanges := c.UserConfig().Gui.ShowNumberOfLineChanges
showNumberOfLineChanges := c.UserConfig().Gui.ShowNumberOfLineChangesFilesView
lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons, showNumberOfLineChanges)
return lo.Map(lines, func(line string, _ int) []string {
return []string{line}
Expand Down
4 changes: 2 additions & 2 deletions schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 913d026

Please sign in to comment.