1
0
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:
Stefan Haller
2023-08-28 13:09:55 +02:00
parent f7db17f7d0
commit 7774fe0ab3
11 changed files with 21 additions and 16 deletions

View File

@ -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.