Skip to content
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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pkg/gui/services/custom_commands/session_state_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ type SessionState struct {
}

func (self *SessionStateLoader) call() *SessionState {
var commit = commitShimFromModelCommit(self.c.Contexts().LocalCommits.GetSelected())
commit := commitShimFromModelCommit(self.c.Contexts().LocalCommits.GetSelected())
path := self.c.Contexts().Files.GetSelectedPath()

if path == "" {
path = self.c.Contexts().CommitFiles.GetSelectedPath()
}
Copy link
Collaborator

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.


if commit == nil {
commit = commitShimFromModelCommit(self.c.Contexts().ReflogCommits.GetSelected())
Expand All @@ -194,7 +199,7 @@ func (self *SessionStateLoader) call() *SessionState {

return &SessionState{
SelectedFile: fileShimFromModelFile(self.c.Contexts().Files.GetSelectedFile()),
SelectedPath: self.c.Contexts().Files.GetSelectedPath(),
SelectedPath: path,
SelectedLocalCommit: commit,
SelectedReflogCommit: commit,
SelectedCommit: commit,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Expand All @@ -204,7 +209,7 @@ func (self *SessionStateLoader) call() *SessionState {
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(),
SelectedCommitFilePath: path,
SelectedSubCommit: commit,
SelectedWorktree: worktreeShimFromModelRemote(self.c.Contexts().Worktrees.GetSelected()),
CheckedOutBranch: branchShimFromModelBranch(self.refsHelper.GetCheckedOutRef()),
Expand Down