Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@stackmystack
Copy link
Contributor

I stringed this in a couple of minutes, so I am not sure whether this is enough.

I tried to look for tests on collapsed sections, and couldn't find something useful.

I'll be happy to add a test if you have a good idea on what to do.

@altsem
Copy link
Owner

altsem commented Jul 15, 2024

Makes sense, I'll test this out soon!
Maybe a more descriptive name in the config file would be nice?

[general]
always_show_help.enabled = false
always_show_help.enabled = false
confirm_quit.enabled = false
confirm_quit.enabled = false
collapsed = []

@stackmystack
Copy link
Contributor Author

Makes sense, I'll test this out soon! Maybe a more descriptive name in the config file would be nice?

collapsed_sections = [] ? collapsed_on_startup = [] ?

[general]
always_show_help.enabled = false
always_show_help.enabled = false
confirm_quit.enabled = false
confirm_quit.enabled = false
collapsed = []

I didn't quite get your comment here, you duplicated some keys and kept collapsed.

@altsem
Copy link
Owner

altsem commented Jul 16, 2024

What the hell did I copy paste x)

Yes, just changing the name of it was my idea. Perhaps 'collapsed_sections' is good enough :)

@stackmystack
Copy link
Contributor Author

Done.

@altsem
Copy link
Owner

altsem commented Jul 17, 2024

An issue I've thought of is that there's no real scheme for ids of items in gitu.
Some are just a copy of the text they contain, some are defined as snake case (like "untracked").

These were put in just in order to have a (hopefully) unique reference to an item that would remain between reloads of data. (so that collapsed sections will remain collapsed on a reload).

Perhaps only these defined sections on the status screen should be configurable?
Section in gitu could be a delta, a hunk etc.

Currently the sections seen on the status screen are also not consistent:

#[test]
fn collapsed_sections_config() {
    let mut ctx = TestContext::setup_clone();
    ctx.config().general.collapsed_sections = vec![
        // TODO Are we doing snake_case or not?
        "untracked".into(),
        "Recent commits".into(),
        "branch_status".into(),
        // TODO rebase / revert/ merge conlict?
    ];
    fs::write(ctx.dir.child("untracked_file.txt"), "").unwrap();

    snapshot!(ctx, "");
}

It would be nice if it's documented in the default config too, exactly which ones can configured as collapsed.

Does that make sense?

@stackmystack
Copy link
Contributor Author

An issue I've thought of is that there's no real scheme for ids of items in gitu. Some are just a copy of the text they contain, some are defined as snake case (like "untracked").

Yes that's why I thought. I think IDs should be snake case, but for the config part, it shouldn't matter. We can take the user text and make it snake_case.

Perhaps only these defined sections on the status screen should be configurable? Section in gitu could be a delta, a hunk etc.

Yeah, well, we can never know what users want, and if we go through the route of unique snake_case IDs, then theoretically it would even be less specific code since we don't have to manage exceptions?

It would be nice if it's documented in the default config too, exactly which ones can configured as collapsed.

I added in the docs the one you included in the tests since they definitely make the most sense ATM.

And since we're at collapsed sections, I noticed that when I press g to refresh the screen and get modifications, the delta for files are open by default, and I think it should be closed by default because in most scenarios, this is what you want.

Comment on lines +8 to +9
# To collapse untracked files by default. e.g.:
# collapsed_sections = ["untracked", "Recent commits", "branch_status"]
Copy link
Owner

Choose a reason for hiding this comment

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

"You can have sections collapsed by default:", or something like that?
I'd like to see these consistent.
recent_commits? Would need to set this id, should be easy.

@altsem
Copy link
Owner

altsem commented Jul 21, 2024

Seems fine to start with these.
The deltas showing per default is a bug from before I think? Could be done in another issue and PR.

@altsem
Copy link
Owner

altsem commented Oct 27, 2024

superseded by #276

@altsem altsem closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants