1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-22 04:42:37 +03:00

Add SelectedSubmodule to SessionState

Introduce the 'SelectedSubmodule' struct and allow using it as a
placeholder value.
Add a corresponding test.
Update the documentation to include it among the listed placeholder
values.
This commit is contained in:
rlkandela
2025-11-11 11:41:33 +01:00
committed by Stefan Haller
parent 7d1c3f7a28
commit 374f0f0766
5 changed files with 74 additions and 0 deletions

View File

@@ -62,6 +62,18 @@ func fileShimFromModelFile(file *models.File) *File {
}
}
func submoduleShimFromModelSubmodule(submodule *models.SubmoduleConfig) *Submodule {
if submodule == nil {
return nil
}
return &Submodule{
Name: submodule.Name,
Path: submodule.Path,
Url: submodule.Url,
}
}
func branchShimFromModelBranch(branch *models.Branch) *Branch {
if branch == nil {
return nil
@@ -186,6 +198,7 @@ type SessionState struct {
SelectedCommit *Commit
SelectedCommitRange *CommitRange
SelectedFile *File
SelectedSubmodule *Submodule
SelectedPath string
SelectedLocalBranch *Branch
SelectedRemoteBranch *RemoteBranch
@@ -225,6 +238,7 @@ func (self *SessionStateLoader) call() *SessionState {
return &SessionState{
SelectedFile: fileShimFromModelFile(self.c.Contexts().Files.GetSelectedFile()),
SelectedSubmodule: submoduleShimFromModelSubmodule(self.c.Contexts().Submodules.GetSelected()),
SelectedPath: selectedPath,
SelectedLocalCommit: selectedLocalCommit,
SelectedReflogCommit: selectedReflogCommit,