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

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
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) struct Config {
pub struct GeneralConfig {
pub always_show_help: BoolConfigEntry,
pub confirm_quit: BoolConfigEntry,
pub collapsed_sections: Vec<String>,
}

#[derive(Default, Debug, Deserialize)]
Expand Down
5 changes: 4 additions & 1 deletion src/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
[general]
always_show_help.enabled = false
confirm_quit.enabled = false
# To collapse untracked files by default. e.g.:
# collapsed_sections = ["untracked", "Recent commits", "branch_status"]
Comment on lines +8 to +9
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.

collapsed_sections = []

[style]
# fg / bg can be either of:
Expand All @@ -29,7 +32,7 @@ diff_highlight.tag_new = { fg = "green", mods = "BOLD" }
diff_highlight.unchanged_old = { mods = "DIM" }
diff_highlight.unchanged_new = { mods = "DIM" }
diff_highlight.changed_old = { fg = "red" }
diff_highlight.changed_new = { fg = "green"}
diff_highlight.changed_new = { fg = "green" }

syntax_highlight.enabled = true
syntax_highlight.attribute = { fg = "yellow" }
Expand Down
9 changes: 8 additions & 1 deletion src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ impl Screen {
size: Rect,
refresh_items: Box<dyn Fn() -> Res<Vec<Item>>>,
) -> Res<Self> {
let collapsed = config
.general
.collapsed_sections
.clone()
.into_iter()
.map(|s| Cow::Owned(s.into()))
.collect();
let mut screen = Self {
cursor: 0,
scroll: 0,
Expand All @@ -44,7 +51,7 @@ impl Screen {
refresh_items,
items: vec![],
line_index: vec![],
collapsed: HashSet::new(),
collapsed,
};

screen.update()?;
Expand Down
14 changes: 14 additions & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ fn binary_file() {
snapshot!(ctx, "jj<tab>");
}

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

snapshot!(ctx, "");
}

#[test]
fn log() {
let ctx = TestContext::setup_clone();
Expand Down
25 changes: 25 additions & 0 deletions src/tests/snapshots/gitu__tests__collapsed_sections_config.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: src/tests/mod.rs
expression: ctx.redact_buffer()
---
▌On branch main… |
|
Untracked files… |
|
Recent commits… |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
styles_hash: cbfd7594a526d60d