From ee62878e6b260645a7a3e1c377ecbea275a50c48 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Jul 2025 15:47:48 +0200 Subject: [PATCH 1/3] Cleanup: remove pointless error handling ForEachFile can't possibly return an error if the passed function doesn't return one. --- pkg/gui/controllers/commits_files_controller.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 8beeb6ff2..2957c8f00 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -319,13 +319,10 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN } for _, node := range selectedNodes { - err := node.ForEachFile(func(file *models.CommitFile) error { + _ = node.ForEachFile(func(file *models.CommitFile) error { filePaths = append(filePaths, file.GetPath()) return nil }) - if err != nil { - return err - } } err := self.c.Git().Rebase.DiscardOldFileChanges(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), filePaths) From 80e20417a831110d6a86c6fcc792d8a29893f461 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Jul 2025 15:49:25 +0200 Subject: [PATCH 2/3] Remove unnecessary refresh CheckMergeOrRebase already calls Refresh. --- pkg/gui/controllers/commits_files_controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 2957c8f00..5529659e0 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -333,7 +333,8 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN if self.context().RangeSelectEnabled() { self.context().GetList().CancelRangeSelect() } - return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC}) + + return nil }) }, }) From 5be97c61456cbfb587edc3e532d2a19a5c40e6d2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Jul 2025 15:49:51 +0200 Subject: [PATCH 3/3] Remove another unnecessary refresh This was added after this PR comment: https://github.com/jesseduffield/lazygit/pull/3276#discussion_r1469077611 > Can we do a refresh after this reset so that the screen shows that the patch > has been cancelled? That way, if we cancel on the next popup, the screen will > be in a valid state. I don't understand what "cancel on the next popup" means; there is no further popup after this code. --- pkg/gui/controllers/commits_files_controller.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 5529659e0..9febcc534 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -313,9 +313,6 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN // Reset the current patch if there is one. if self.c.Git().Patch.PatchBuilder.Active() { self.c.Git().Patch.PatchBuilder.Reset() - if err := self.c.Refresh(types.RefreshOptions{Mode: types.BLOCK_UI}); err != nil { - return err - } } for _, node := range selectedNodes {