diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-21 12:48:49 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-06 22:37:28 +1100 |
commit | 1996eddd9124709431ced14b1650ae5a50963be7 (patch) | |
tree | 021b88b94139b21beae4cae92b9f0a119e7361f2 /pkg/gui/diff_context_size.go | |
parent | de0e885c65c7d6505055af490e58c21aad59f67e (diff) |
more efficient context diff size changing
Diffstat (limited to 'pkg/gui/diff_context_size.go')
-rw-r--r-- | pkg/gui/diff_context_size.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go index a54a9c418..fdf147496 100644 --- a/pkg/gui/diff_context_size.go +++ b/pkg/gui/diff_context_size.go @@ -1,5 +1,9 @@ package gui +import ( + "errors" +) + func isShowingDiff(gui *Gui) bool { key := gui.currentStaticContext().GetKey() @@ -8,8 +12,12 @@ func isShowingDiff(gui *Gui) bool { func (gui *Gui) IncreaseContextInDiffView() error { if isShowingDiff(gui) { + if err := gui.CheckCanChangeContext(); err != nil { + return gui.surfaceError(err) + } + gui.Config.GetUserConfig().Git.DiffContextSize = gui.Config.GetUserConfig().Git.DiffContextSize + 1 - return gui.postRefreshUpdate(gui.currentStaticContext()) + return gui.currentStaticContext().HandleRenderToMain() } return nil @@ -19,8 +27,20 @@ func (gui *Gui) DecreaseContextInDiffView() error { old_size := gui.Config.GetUserConfig().Git.DiffContextSize if isShowingDiff(gui) && old_size > 1 { + if err := gui.CheckCanChangeContext(); err != nil { + return gui.surfaceError(err) + } + gui.Config.GetUserConfig().Git.DiffContextSize = old_size - 1 - return gui.postRefreshUpdate(gui.currentStaticContext()) + return gui.currentStaticContext().HandleRenderToMain() + } + + return nil +} + +func (gui *Gui) CheckCanChangeContext() error { + if gui.GitCommand.PatchManager.Active() { + return errors.New(gui.Tr.CantChangeContextSizeError) } return nil |