mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Move diff context size from UserConfig to AppState
This commit is contained in:
@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
@ -65,7 +66,7 @@ func (self *ContextLinesController) Increase() error {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
self.c.UserConfig.Git.DiffContextSize = self.c.UserConfig.Git.DiffContextSize + 1
|
||||
self.c.AppState.DiffContextSize++
|
||||
return self.applyChange()
|
||||
}
|
||||
|
||||
@ -73,14 +74,14 @@ func (self *ContextLinesController) Increase() error {
|
||||
}
|
||||
|
||||
func (self *ContextLinesController) Decrease() error {
|
||||
old_size := self.c.UserConfig.Git.DiffContextSize
|
||||
old_size := self.c.AppState.DiffContextSize
|
||||
|
||||
if self.isShowingDiff() && old_size > 1 {
|
||||
if err := self.checkCanChangeContext(); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
self.c.UserConfig.Git.DiffContextSize = old_size - 1
|
||||
self.c.AppState.DiffContextSize = old_size - 1
|
||||
return self.applyChange()
|
||||
}
|
||||
|
||||
@ -88,6 +89,9 @@ func (self *ContextLinesController) Decrease() error {
|
||||
}
|
||||
|
||||
func (self *ContextLinesController) applyChange() error {
|
||||
self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.AppState.DiffContextSize))
|
||||
self.c.SaveAppStateAndLogError()
|
||||
|
||||
currentContext := self.c.CurrentStaticContext()
|
||||
switch currentContext.GetKey() {
|
||||
// we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards.
|
||||
|
Reference in New Issue
Block a user