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

better 'current branch' visualisation #365

Closed
extrawurst opened this issue Oct 25, 2020 · 2 comments · Fixed by #375
Closed

better 'current branch' visualisation #365

extrawurst opened this issue Oct 25, 2020 · 2 comments · Fixed by #375
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@extrawurst
Copy link
Owner

since #362 we now show the outgoing/incoming commits relative to the current branch in a more spacious place in the left_chunks of the status tab.

it would be great to move the actual name of the current branch next to ity:

  • this gives the branch name more room
  • keeps it in focus
  • allows us to cleanup the weird placement of it in the ChangesComponent

see draw_branch_state in status.rs

@extrawurst extrawurst added enhancement New feature or request good first issue Good for newcomers labels Oct 25, 2020
@extrawurst extrawurst added this to the v0.11 milestone Oct 25, 2020
@remique
Copy link
Contributor

remique commented Oct 26, 2020

Hello. I am very new to both Rust and open source, but I have tried to solve this issue.

If I understood correctly, this is the expected outcome:
Zrzut ekranu 2020-10-26 o 01 40 24

My solution was to create a variable inside draw_branch_state function:

let mut branch_name = cached::BranchName::new(CWD);

if let Ok(branch_name) = branch_name.lookup() {
    let w = Paragraph::new(format!(
            "\u{2191}{} \u{2193}{} {{{}}}",
            self.git_branch_state.ahead, self.git_branch_state.behind,
            branch_name
            ))
        .alignment(Alignment::Right);

Reason being, I couldn't add git_branch_name: cached::BranchName inside Status struct. Maybe I am too much of a beginner, but lookup() function returns mutable reference to self, while draw_branch_state takes immutable reference, so it seems impossible to set BranchName correctly (at least inside draw_branch_state). And I do not think that I should mess with lower level structures in this case, as it is labeled as good first issue :)

Anyway, there is now problem of update function inside changes.rs:

pub fn update(&mut self) -> result<()> {
    if self.is_working_dir {
        if let ok(_branch_name) = self.branch_name.lookup() {
            self.files.set_title(format!(
                "{}",
                &self.title, 
            ))
        }
    }
    ok(())
}

Can't get rid of the lookup(), because of ChangesComponent and its uses inside status.rs. So for now I have underscored branch_name.

Should I make PR? This seems like a very temporary solution.

@extrawurst
Copy link
Owner Author

hey @remique thanks for jumping on this. you can do the lookup in update of status.rs just like we had to do previously in ChangesComponent all the places in status.rs that previously referenced self.index_wd.branch_name() can the use the local cached::BranchName that indeed we need in status.rs. feel free to open a PR where we can easier collaborate over comments and specific code 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants