Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 10 additions & 4 deletions src/ui/files_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,16 @@ impl FilesTab {

impl Component for FilesTab {
fn focus(&mut self, commander: &mut Commander) -> Result<()> {
self.is_current_head = self.head == commander.get_current_head()?;
self.head = commander.get_head_latest(&self.head)?;
self.refresh_files(commander)?;
self.refresh_diff(commander)?;
match commander.get_head_latest(&self.head) {
Ok(latest_head) => {
self.head = latest_head;
self.is_current_head = self.head == commander.get_current_head()?;
self.refresh_files(commander)?;
self.refresh_diff(commander)?;
}
_ => self.set_head(commander, &commander.get_current_head()?)?,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think self.set_head(..) will set current head, refresh files, and refresh diff. Why not call self.set_head in both cases? This would lead to a simpler solution (warning! not tested with compiler)

let next_head = commander.get_head_latest(&self.head)
  .or_else(|_| commander.get_current_head())?;
self.set_head(commander, next_head);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was something that I thought made this necessary, but neither did I document it, nor can I recall it, and @Edgpaez's fix seems to work just fine. And we likely can't merge this PR anyway due to having no reviewers 🤷🏻

Ok(())
}

Expand Down
11 changes: 8 additions & 3 deletions src/ui/log_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,14 @@ impl<'a> LogTab<'a> {

impl Component for LogTab<'_> {
fn focus(&mut self, commander: &mut Commander) -> Result<()> {
let latest_head = commander.get_head_latest(&self.head)?;
self.log_panel.set_head(latest_head);
self.sync_head_output(commander);
match commander.get_head_latest(&self.head) {
Ok(latest_head) => {
self.log_panel.set_head(latest_head);
self.sync_head_output(commander);
}
_ => self.set_head(commander, commander.get_current_head()?),
}

Ok(())
}

Expand Down
Loading