1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-23 17:48:30 +03:00

When entering a commit in path filtering mode, select the filtered path

This commit is contained in:
Stefan Haller
2025-10-06 10:31:24 +02:00
parent 5811f2945c
commit 7fe73c1ee2
5 changed files with 119 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package controllers
import (
"path/filepath"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -90,6 +92,15 @@ func (self *SwitchToDiffFilesController) enter() error {
Scope: []types.RefreshableView{types.COMMIT_FILES},
})
if filterPath := self.c.Modes().Filtering.GetPath(); filterPath != "" {
path, err := filepath.Rel(self.c.Git().RepoPaths.RepoPath(), filterPath)
if err != nil {
path = filterPath
}
commitFilesContext.CommitFileTreeViewModel.SelectPath(
filepath.ToSlash(path), self.c.UserConfig().Gui.ShowRootItemInFileTree)
}
self.c.Context().Push(commitFilesContext, types.OnFocusOpts{})
return nil
}