-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make SelectedCommit and SelectedPath Generic for all views #3752
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,7 @@ type SessionState struct { | |
SelectedLocalCommit *Commit | ||
SelectedReflogCommit *Commit | ||
SelectedSubCommit *Commit | ||
SelectedCommit *Commit | ||
SelectedFile *File | ||
SelectedPath string | ||
SelectedLocalBranch *Branch | ||
|
@@ -181,19 +182,35 @@ type SessionState struct { | |
} | ||
|
||
func (self *SessionStateLoader) call() *SessionState { | ||
commit := commitShimFromModelCommit(self.c.Contexts().LocalCommits.GetSelected()) | ||
path := self.c.Contexts().Files.GetSelectedPath() | ||
|
||
if path == "" { | ||
path = self.c.Contexts().CommitFiles.GetSelectedPath() | ||
} | ||
|
||
if commit == nil { | ||
commit = commitShimFromModelCommit(self.c.Contexts().ReflogCommits.GetSelected()) | ||
|
||
if commit == nil { | ||
commit = commitShimFromModelCommit(self.c.Contexts().SubCommits.GetSelected()) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic doesn't make sense: we need to test which panel is focused, and set commit to LocalCommits.GetSelected() if it's the local commits panel, or to ReflogCommits.GetSelected() if it's the reflogs panel, or to SubCommits.GetSelected() if it's the subcommits panel. Or to nil if it's not any of these, although we might consider setting it to LocalCommits.GetSelected() in that case because that's probably a useful default. I think you can use |
||
|
||
return &SessionState{ | ||
SelectedFile: fileShimFromModelFile(self.c.Contexts().Files.GetSelectedFile()), | ||
SelectedPath: self.c.Contexts().Files.GetSelectedPath(), | ||
SelectedLocalCommit: commitShimFromModelCommit(self.c.Contexts().LocalCommits.GetSelected()), | ||
SelectedReflogCommit: commitShimFromModelCommit(self.c.Contexts().ReflogCommits.GetSelected()), | ||
SelectedPath: path, | ||
SelectedLocalCommit: commit, | ||
SelectedReflogCommit: commit, | ||
SelectedCommit: commit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is backwards. We need to keep setting SelectedLocalCommit, SelectedReflogCommit, and SelectedSubCommit to what they were set to before, for backwards compatibility. Only SelectedCommit will point to one of them, depending on context; see above. |
||
SelectedLocalBranch: branchShimFromModelBranch(self.c.Contexts().Branches.GetSelected()), | ||
SelectedRemoteBranch: remoteBranchShimFromModelRemoteBranch(self.c.Contexts().RemoteBranches.GetSelected()), | ||
SelectedRemote: remoteShimFromModelRemote(self.c.Contexts().Remotes.GetSelected()), | ||
SelectedTag: tagShimFromModelRemote(self.c.Contexts().Tags.GetSelected()), | ||
SelectedStashEntry: stashEntryShimFromModelRemote(self.c.Contexts().Stash.GetSelected()), | ||
SelectedCommitFile: commitFileShimFromModelRemote(self.c.Contexts().CommitFiles.GetSelectedFile()), | ||
SelectedCommitFilePath: self.c.Contexts().CommitFiles.GetSelectedPath(), | ||
SelectedSubCommit: commitShimFromModelCommit(self.c.Contexts().SubCommits.GetSelected()), | ||
SelectedCommitFilePath: path, | ||
SelectedSubCommit: commit, | ||
SelectedWorktree: worktreeShimFromModelRemote(self.c.Contexts().Worktrees.GetSelected()), | ||
CheckedOutBranch: branchShimFromModelBranch(self.refsHelper.GetCheckedOutRef()), | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; testing if path is empty doesn't make sense. We need to set SelectedPath to either Files.GetSelectedPath() or CommitFiles.GetSelectedPath(), depending on which view is focused.