mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Move DiffContextSize and RenameSimilarityThreshold to user config
This commit is contained in:
@ -369,6 +369,12 @@ git:
|
|||||||
# If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `<c-w>`.
|
# If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `<c-w>`.
|
||||||
ignoreWhitespaceInDiffView: false
|
ignoreWhitespaceInDiffView: false
|
||||||
|
|
||||||
|
# The number of lines of context to show around each diff hunk. Can be changed from within Lazygit with the `{` and `}` keys.
|
||||||
|
diffContextSize: 3
|
||||||
|
|
||||||
|
# The threshold for considering a file to be renamed, in percent. Can be changed from within Lazygit with the `(` and `)` keys.
|
||||||
|
renameSimilarityThreshold: 50
|
||||||
|
|
||||||
# If true, do not spawn a separate process when using GPG
|
# If true, do not spawn a separate process when using GPG
|
||||||
overrideGpg: false
|
overrideGpg: false
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ func (self *CommitCommands) AmendHeadCmdObj() *oscommands.CmdObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) ShowCmdObj(hash string, filterPath string) *oscommands.CmdObj {
|
func (self *CommitCommands) ShowCmdObj(hash string, filterPath string) *oscommands.CmdObj {
|
||||||
contextSize := self.AppState.DiffContextSize
|
contextSize := self.UserConfig().Git.DiffContextSize
|
||||||
|
|
||||||
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
|
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
|
||||||
cmdArgs := NewGitCmd("show").
|
cmdArgs := NewGitCmd("show").
|
||||||
@ -269,7 +269,7 @@ func (self *CommitCommands) ShowCmdObj(hash string, filterPath string) *oscomman
|
|||||||
Arg("-p").
|
Arg("-p").
|
||||||
Arg(hash).
|
Arg(hash).
|
||||||
ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
||||||
Arg(fmt.Sprintf("--find-renames=%d%%", self.AppState.RenameSimilarityThreshold)).
|
Arg(fmt.Sprintf("--find-renames=%d%%", self.UserConfig().Git.RenameSimilarityThreshold)).
|
||||||
ArgIf(filterPath != "", "--", filterPath).
|
ArgIf(filterPath != "", "--", filterPath).
|
||||||
Dir(self.repoPaths.worktreePath).
|
Dir(self.repoPaths.worktreePath).
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
@ -321,15 +321,14 @@ func TestCommitShowCmdObj(t *testing.T) {
|
|||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.Paging.ExternalDiffCommand = s.extDiffCmd
|
userConfig.Git.Paging.ExternalDiffCommand = s.extDiffCmd
|
||||||
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
||||||
appState := &config.AppState{}
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
appState.DiffContextSize = s.contextSize
|
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
|
||||||
appState.RenameSimilarityThreshold = s.similarityThreshold
|
|
||||||
|
|
||||||
runner := oscommands.NewFakeRunner(t).ExpectGitArgs(s.expected, "", nil)
|
runner := oscommands.NewFakeRunner(t).ExpectGitArgs(s.expected, "", nil)
|
||||||
repoPaths := RepoPaths{
|
repoPaths := RepoPaths{
|
||||||
worktreePath: "/path/to/worktree",
|
worktreePath: "/path/to/worktree",
|
||||||
}
|
}
|
||||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig, appState: appState, runner: runner, repoPaths: &repoPaths})
|
instance := buildCommitCommands(commonDeps{userConfig: userConfig, appState: &config.AppState{}, runner: runner, repoPaths: &repoPaths})
|
||||||
|
|
||||||
assert.NoError(t, instance.ShowCmdObj("1234567890", s.filterPath).Run())
|
assert.NoError(t, instance.ShowCmdObj("1234567890", s.filterPath).Run())
|
||||||
runner.CheckForMissingCalls()
|
runner.CheckForMissingCalls()
|
||||||
|
@ -31,7 +31,7 @@ func (self *DiffCommands) DiffCmdObj(diffArgs []string) *oscommands.CmdObj {
|
|||||||
Arg("--submodule").
|
Arg("--submodule").
|
||||||
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
|
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
|
||||||
ArgIf(ignoreWhitespace, "--ignore-all-space").
|
ArgIf(ignoreWhitespace, "--ignore-all-space").
|
||||||
Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)).
|
Arg(fmt.Sprintf("--unified=%d", self.UserConfig().Git.DiffContextSize)).
|
||||||
Arg(diffArgs...).
|
Arg(diffArgs...).
|
||||||
Dir(self.repoPaths.worktreePath).
|
Dir(self.repoPaths.worktreePath).
|
||||||
ToArgv(),
|
ToArgv(),
|
||||||
|
@ -175,7 +175,7 @@ func (self *FileLoader) gitStatus(opts GitStatusOptions) ([]FileStatus, error) {
|
|||||||
ArgIfElse(
|
ArgIfElse(
|
||||||
opts.NoRenames,
|
opts.NoRenames,
|
||||||
"--no-renames",
|
"--no-renames",
|
||||||
fmt.Sprintf("--find-renames=%d%%", self.AppState.RenameSimilarityThreshold),
|
fmt.Sprintf("--find-renames=%d%%", self.UserConfig().Git.RenameSimilarityThreshold),
|
||||||
).
|
).
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
|
||||||
|
@ -198,17 +198,12 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
||||||
|
|
||||||
appState := &config.AppState{}
|
userConfig := &config.UserConfig{}
|
||||||
appState.RenameSimilarityThreshold = s.similarityThreshold
|
userConfig.Gui.ShowNumstatInFilesView = s.showNumstatInFilesView
|
||||||
|
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
|
||||||
userConfig := &config.UserConfig{
|
|
||||||
Gui: config.GuiConfig{
|
|
||||||
ShowNumstatInFilesView: s.showNumstatInFilesView,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
loader := &FileLoader{
|
loader := &FileLoader{
|
||||||
GitCommon: buildGitCommon(commonDeps{appState: appState, userConfig: userConfig}),
|
GitCommon: buildGitCommon(commonDeps{appState: &config.AppState{}, userConfig: userConfig}),
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
config: &FakeFileLoaderConfig{showUntrackedFiles: "yes"},
|
config: &FakeFileLoaderConfig{showUntrackedFiles: "yes"},
|
||||||
getFileType: func(string) string { return "file" },
|
getFileType: func(string) string { return "file" },
|
||||||
|
@ -87,9 +87,9 @@ func (self *StashCommands) ShowStashEntryCmdObj(index int) *oscommands.CmdObj {
|
|||||||
Arg("--stat").
|
Arg("--stat").
|
||||||
Arg("-u").
|
Arg("-u").
|
||||||
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
|
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
|
||||||
Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)).
|
Arg(fmt.Sprintf("--unified=%d", self.UserConfig().Git.DiffContextSize)).
|
||||||
ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
||||||
Arg(fmt.Sprintf("--find-renames=%d%%", self.AppState.RenameSimilarityThreshold)).
|
Arg(fmt.Sprintf("--find-renames=%d%%", self.UserConfig().Git.RenameSimilarityThreshold)).
|
||||||
Arg(fmt.Sprintf("refs/stash@{%d}", index)).
|
Arg(fmt.Sprintf("refs/stash@{%d}", index)).
|
||||||
Dir(self.repoPaths.worktreePath).
|
Dir(self.repoPaths.worktreePath).
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
@ -145,13 +145,12 @@ func TestStashStashEntryCmdObj(t *testing.T) {
|
|||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
||||||
appState := &config.AppState{}
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
appState.DiffContextSize = s.contextSize
|
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
|
||||||
appState.RenameSimilarityThreshold = s.similarityThreshold
|
|
||||||
repoPaths := RepoPaths{
|
repoPaths := RepoPaths{
|
||||||
worktreePath: "/path/to/worktree",
|
worktreePath: "/path/to/worktree",
|
||||||
}
|
}
|
||||||
instance := buildStashCommands(commonDeps{userConfig: userConfig, appState: appState, repoPaths: &repoPaths})
|
instance := buildStashCommands(commonDeps{userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||||
|
|
||||||
cmdStr := instance.ShowStashEntryCmdObj(s.index).Args()
|
cmdStr := instance.ShowStashEntryCmdObj(s.index).Args()
|
||||||
assert.Equal(t, s.expected, cmdStr)
|
assert.Equal(t, s.expected, cmdStr)
|
||||||
|
@ -260,7 +260,7 @@ func (self *WorkingTreeCommands) WorktreeFileDiffCmdObj(node models.IFile, plain
|
|||||||
colorArg = "never"
|
colorArg = "never"
|
||||||
}
|
}
|
||||||
|
|
||||||
contextSize := self.AppState.DiffContextSize
|
contextSize := self.UserConfig().Git.DiffContextSize
|
||||||
prevPath := node.GetPreviousPath()
|
prevPath := node.GetPreviousPath()
|
||||||
noIndex := !node.GetIsTracked() && !node.GetHasStagedChanges() && !cached && node.GetIsFile()
|
noIndex := !node.GetIsTracked() && !node.GetHasStagedChanges() && !cached && node.GetIsFile()
|
||||||
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
|
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
|
||||||
@ -273,7 +273,7 @@ func (self *WorkingTreeCommands) WorktreeFileDiffCmdObj(node models.IFile, plain
|
|||||||
Arg(fmt.Sprintf("--unified=%d", contextSize)).
|
Arg(fmt.Sprintf("--unified=%d", contextSize)).
|
||||||
Arg(fmt.Sprintf("--color=%s", colorArg)).
|
Arg(fmt.Sprintf("--color=%s", colorArg)).
|
||||||
ArgIf(!plain && self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
ArgIf(!plain && self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
||||||
Arg(fmt.Sprintf("--find-renames=%d%%", self.AppState.RenameSimilarityThreshold)).
|
Arg(fmt.Sprintf("--find-renames=%d%%", self.UserConfig().Git.RenameSimilarityThreshold)).
|
||||||
ArgIf(cached, "--cached").
|
ArgIf(cached, "--cached").
|
||||||
ArgIf(noIndex, "--no-index").
|
ArgIf(noIndex, "--no-index").
|
||||||
Arg("--").
|
Arg("--").
|
||||||
@ -293,7 +293,7 @@ func (self *WorkingTreeCommands) ShowFileDiff(from string, to string, reverse bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reverse bool, fileName string, plain bool) *oscommands.CmdObj {
|
func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reverse bool, fileName string, plain bool) *oscommands.CmdObj {
|
||||||
contextSize := self.AppState.DiffContextSize
|
contextSize := self.UserConfig().Git.DiffContextSize
|
||||||
|
|
||||||
colorArg := self.UserConfig().Git.Paging.ColorArg
|
colorArg := self.UserConfig().Git.Paging.ColorArg
|
||||||
if plain {
|
if plain {
|
||||||
|
@ -328,14 +328,13 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
||||||
appState := &config.AppState{}
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
appState.DiffContextSize = s.contextSize
|
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
|
||||||
appState.RenameSimilarityThreshold = s.similarityThreshold
|
|
||||||
repoPaths := RepoPaths{
|
repoPaths := RepoPaths{
|
||||||
worktreePath: "/path/to/worktree",
|
worktreePath: "/path/to/worktree",
|
||||||
}
|
}
|
||||||
|
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: appState, repoPaths: &repoPaths})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||||
result := instance.WorktreeFileDiff(s.file, s.plain, s.cached)
|
result := instance.WorktreeFileDiff(s.file, s.plain, s.cached)
|
||||||
assert.Equal(t, expectedResult, result)
|
assert.Equal(t, expectedResult, result)
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
@ -397,13 +396,12 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
|
|||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
|
||||||
appState := &config.AppState{}
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
appState.DiffContextSize = s.contextSize
|
|
||||||
repoPaths := RepoPaths{
|
repoPaths := RepoPaths{
|
||||||
worktreePath: "/path/to/worktree",
|
worktreePath: "/path/to/worktree",
|
||||||
}
|
}
|
||||||
|
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: appState, repoPaths: &repoPaths})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||||
|
|
||||||
result, err := instance.ShowFileDiff(s.from, s.to, s.reverse, "test.txt", s.plain)
|
result, err := instance.ShowFileDiff(s.from, s.to, s.reverse, "test.txt", s.plain)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -677,8 +677,6 @@ type AppState struct {
|
|||||||
ShellCommandsHistory []string `yaml:"customcommandshistory"`
|
ShellCommandsHistory []string `yaml:"customcommandshistory"`
|
||||||
|
|
||||||
HideCommandLog bool
|
HideCommandLog bool
|
||||||
DiffContextSize uint64
|
|
||||||
RenameSimilarityThreshold int
|
|
||||||
LocalBranchSortOrder string
|
LocalBranchSortOrder string
|
||||||
RemoteBranchSortOrder string
|
RemoteBranchSortOrder string
|
||||||
|
|
||||||
@ -698,8 +696,6 @@ func getDefaultAppState() *AppState {
|
|||||||
RecentRepos: []string{},
|
RecentRepos: []string{},
|
||||||
StartupPopupVersion: 0,
|
StartupPopupVersion: 0,
|
||||||
LastVersion: "",
|
LastVersion: "",
|
||||||
DiffContextSize: 3,
|
|
||||||
RenameSimilarityThreshold: 50,
|
|
||||||
LocalBranchSortOrder: "recency",
|
LocalBranchSortOrder: "recency",
|
||||||
RemoteBranchSortOrder: "alphabetical",
|
RemoteBranchSortOrder: "alphabetical",
|
||||||
GitLogOrder: "", // should be "topo-order" eventually
|
GitLogOrder: "", // should be "topo-order" eventually
|
||||||
|
@ -266,6 +266,10 @@ type GitConfig struct {
|
|||||||
AllBranchesLogCmds []string `yaml:"allBranchesLogCmds"`
|
AllBranchesLogCmds []string `yaml:"allBranchesLogCmds"`
|
||||||
// If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `<c-w>`.
|
// If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `<c-w>`.
|
||||||
IgnoreWhitespaceInDiffView bool `yaml:"ignoreWhitespaceInDiffView"`
|
IgnoreWhitespaceInDiffView bool `yaml:"ignoreWhitespaceInDiffView"`
|
||||||
|
// The number of lines of context to show around each diff hunk. Can be changed from within Lazygit with the `{` and `}` keys.
|
||||||
|
DiffContextSize uint64 `yaml:"diffContextSize"`
|
||||||
|
// The threshold for considering a file to be renamed, in percent. Can be changed from within Lazygit with the `(` and `)` keys.
|
||||||
|
RenameSimilarityThreshold int `yaml:"renameSimilarityThreshold" jsonschema:"minimum=0,maximum=100"`
|
||||||
// If true, do not spawn a separate process when using GPG
|
// If true, do not spawn a separate process when using GPG
|
||||||
OverrideGpg bool `yaml:"overrideGpg"`
|
OverrideGpg bool `yaml:"overrideGpg"`
|
||||||
// If true, do not allow force pushes
|
// If true, do not allow force pushes
|
||||||
@ -811,6 +815,8 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
BranchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --",
|
BranchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --",
|
||||||
AllBranchesLogCmds: []string{"git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium"},
|
AllBranchesLogCmds: []string{"git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium"},
|
||||||
IgnoreWhitespaceInDiffView: false,
|
IgnoreWhitespaceInDiffView: false,
|
||||||
|
DiffContextSize: 3,
|
||||||
|
RenameSimilarityThreshold: 50,
|
||||||
DisableForcePushing: false,
|
DisableForcePushing: false,
|
||||||
CommitPrefixes: map[string][]CommitPrefixConfig(nil),
|
CommitPrefixes: map[string][]CommitPrefixConfig(nil),
|
||||||
BranchPrefix: "",
|
BranchPrefix: "",
|
||||||
|
@ -378,7 +378,7 @@ func (self *CommitFilesController) openDiffTool(node *filetree.CommitFileNode) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.CommitFileNode) error {
|
func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.CommitFileNode) error {
|
||||||
if self.c.AppState.DiffContextSize == 0 {
|
if self.c.UserConfig().Git.DiffContextSize == 0 {
|
||||||
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextForCustomPatch,
|
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextForCustomPatch,
|
||||||
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode
|
|||||||
return self.handleToggleCommitFileDirCollapsed(node)
|
return self.handleToggleCommitFileDirCollapsed(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.c.AppState.DiffContextSize == 0 {
|
if self.c.UserConfig().Git.DiffContextSize == 0 {
|
||||||
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextForCustomPatch,
|
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextForCustomPatch,
|
||||||
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,8 @@ func (self *ContextLinesController) Increase() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.c.AppState.DiffContextSize < math.MaxUint64 {
|
if self.c.UserConfig().Git.DiffContextSize < math.MaxUint64 {
|
||||||
self.c.AppState.DiffContextSize++
|
self.c.UserConfig().Git.DiffContextSize++
|
||||||
}
|
}
|
||||||
return self.applyChange()
|
return self.applyChange()
|
||||||
}
|
}
|
||||||
@ -86,8 +86,8 @@ func (self *ContextLinesController) Decrease() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.c.AppState.DiffContextSize > 0 {
|
if self.c.UserConfig().Git.DiffContextSize > 0 {
|
||||||
self.c.AppState.DiffContextSize--
|
self.c.UserConfig().Git.DiffContextSize--
|
||||||
}
|
}
|
||||||
return self.applyChange()
|
return self.applyChange()
|
||||||
}
|
}
|
||||||
@ -96,8 +96,7 @@ func (self *ContextLinesController) Decrease() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *ContextLinesController) applyChange() error {
|
func (self *ContextLinesController) applyChange() error {
|
||||||
self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.AppState.DiffContextSize))
|
self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.UserConfig().Git.DiffContextSize))
|
||||||
self.c.SaveAppStateAndLogError()
|
|
||||||
|
|
||||||
currentContext := self.currentSidePanel()
|
currentContext := self.currentSidePanel()
|
||||||
switch currentContext.GetKey() {
|
switch currentContext.GetKey() {
|
||||||
|
@ -59,10 +59,10 @@ func (self *RenameSimilarityThresholdController) Context() types.Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *RenameSimilarityThresholdController) Increase() error {
|
func (self *RenameSimilarityThresholdController) Increase() error {
|
||||||
old_size := self.c.AppState.RenameSimilarityThreshold
|
old_size := self.c.UserConfig().Git.RenameSimilarityThreshold
|
||||||
|
|
||||||
if self.isShowingRenames() && old_size < 100 {
|
if self.isShowingRenames() && old_size < 100 {
|
||||||
self.c.AppState.RenameSimilarityThreshold = min(100, old_size+5)
|
self.c.UserConfig().Git.RenameSimilarityThreshold = min(100, old_size+5)
|
||||||
return self.applyChange()
|
return self.applyChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +70,10 @@ func (self *RenameSimilarityThresholdController) Increase() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *RenameSimilarityThresholdController) Decrease() error {
|
func (self *RenameSimilarityThresholdController) Decrease() error {
|
||||||
old_size := self.c.AppState.RenameSimilarityThreshold
|
old_size := self.c.UserConfig().Git.RenameSimilarityThreshold
|
||||||
|
|
||||||
if self.isShowingRenames() && old_size > 5 {
|
if self.isShowingRenames() && old_size > 5 {
|
||||||
self.c.AppState.RenameSimilarityThreshold = max(5, old_size-5)
|
self.c.UserConfig().Git.RenameSimilarityThreshold = max(5, old_size-5)
|
||||||
return self.applyChange()
|
return self.applyChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +81,7 @@ func (self *RenameSimilarityThresholdController) Decrease() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *RenameSimilarityThresholdController) applyChange() error {
|
func (self *RenameSimilarityThresholdController) applyChange() error {
|
||||||
self.c.Toast(fmt.Sprintf(self.c.Tr.RenameSimilarityThresholdChanged, self.c.AppState.RenameSimilarityThreshold))
|
self.c.Toast(fmt.Sprintf(self.c.Tr.RenameSimilarityThresholdChanged, self.c.UserConfig().Git.RenameSimilarityThreshold))
|
||||||
self.c.SaveAppStateAndLogError()
|
|
||||||
|
|
||||||
currentContext := self.currentSidePanel()
|
currentContext := self.currentSidePanel()
|
||||||
switch currentContext.GetKey() {
|
switch currentContext.GetKey() {
|
||||||
|
@ -187,7 +187,7 @@ func (self *StagingController) TogglePanel() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *StagingController) ToggleStaged() error {
|
func (self *StagingController) ToggleStaged() error {
|
||||||
if self.c.AppState.DiffContextSize == 0 {
|
if self.c.UserConfig().Git.DiffContextSize == 0 {
|
||||||
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToStage,
|
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToStage,
|
||||||
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ func (self *StagingController) ToggleStaged() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *StagingController) DiscardSelection() error {
|
func (self *StagingController) DiscardSelection() error {
|
||||||
if self.c.AppState.DiffContextSize == 0 {
|
if self.c.UserConfig().Git.DiffContextSize == 0 {
|
||||||
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToDiscard,
|
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToDiscard,
|
||||||
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
|
||||||
}
|
}
|
||||||
|
@ -364,6 +364,18 @@
|
|||||||
"description": "If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `\u003cc-w\u003e`.",
|
"description": "If true, git diffs are rendered with the `--ignore-all-space` flag, which ignores whitespace changes. Can be toggled from within Lazygit with `\u003cc-w\u003e`.",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
"diffContextSize": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The number of lines of context to show around each diff hunk. Can be changed from within Lazygit with the `{` and `}` keys.",
|
||||||
|
"default": 3
|
||||||
|
},
|
||||||
|
"renameSimilarityThreshold": {
|
||||||
|
"type": "integer",
|
||||||
|
"maximum": 100,
|
||||||
|
"minimum": 0,
|
||||||
|
"description": "The threshold for considering a file to be renamed, in percent. Can be changed from within Lazygit with the `(` and `)` keys.",
|
||||||
|
"default": 50
|
||||||
|
},
|
||||||
"overrideGpg": {
|
"overrideGpg": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, do not spawn a separate process when using GPG",
|
"description": "If true, do not spawn a separate process when using GPG",
|
||||||
|
Reference in New Issue
Block a user