1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-28 04:14:56 +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

@@ -191,3 +191,15 @@ func (self *CommitFileTreeViewModel) ExpandAll() {
self.SetSelectedLineIdx(index)
}
}
// Try to select the given path if present. If it doesn't exist, or one of the parent directories is
// collapsed, do nothing.
// Note that filepath is an actual file path, not an internal tree path as with e.g.
// ToggleCollapsed. It must be a relative path (relative to the repo root), and it must contain
// forward slashes rather than backslashes even on Windows.
func (self *CommitFileTreeViewModel) SelectPath(filepath string, showRootItem bool) {
index, found := self.GetIndexForPath(InternalTreePathForFilePath(filepath, showRootItem))
if found {
self.SetSelection(index)
}
}