Skip to content

Commit 5a45af4

Browse files
committed
Apply rustfmt formatting to dialog and test files
1 parent c345bb9 commit 5a45af4

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

src/commands/interactive/dialog.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,23 @@ impl CreateDialog {
171171
}
172172

173173
// Calculate initial scroll position to center default branch
174-
let selected_line = base_indices
175-
.get(base_selected)
176-
.and_then(|(target_group, target_option)| {
177-
flat_lines.iter().position(|line| {
178-
matches!(
179-
line,
180-
LineType::BranchOption { group_idx, option_idx }
181-
if group_idx == target_group && option_idx == target_option
182-
)
183-
})
184-
});
174+
let selected_line =
175+
base_indices
176+
.get(base_selected)
177+
.and_then(|(target_group, target_option)| {
178+
flat_lines.iter().position(|line| {
179+
matches!(
180+
line,
181+
LineType::BranchOption { group_idx, option_idx }
182+
if group_idx == target_group && option_idx == target_option
183+
)
184+
})
185+
});
185186

186187
// Use reasonable default for initial visible height
187188
let initial_content_height = 6; // Conservative estimate
188-
let scroll_offset = calculate_initial_scroll(selected_line, flat_lines.len(), initial_content_height);
189+
let scroll_offset =
190+
calculate_initial_scroll(selected_line, flat_lines.len(), initial_content_height);
189191
let last_known_height = 0; // Will be set on first render
190192

191193
Self {

src/commands/interactive/tests.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,11 @@ fn down_with_no_worktrees_opens_create_dialog() -> Result<()> {
677677

678678
#[test]
679679
fn find_selected_line_locates_branch_in_flat_lines() {
680-
let branches = vec!["main".to_string(), "develop".to_string(), "feature".to_string()];
680+
let branches = vec![
681+
"main".to_string(),
682+
"develop".to_string(),
683+
"feature".to_string(),
684+
];
681685
let dialog = dialog::CreateDialog::new(&branches, &[], Some("develop"));
682686

683687
let selected_line = dialog.find_selected_line();
@@ -766,7 +770,10 @@ fn scroll_offset_never_exceeds_content_bounds() {
766770
dialog.ensure_selected_visible(visible_height);
767771

768772
let max_offset = dialog.flat_lines.len().saturating_sub(visible_height);
769-
assert_eq!(dialog.scroll_offset, 0, "scroll should be 0 when viewport larger than content");
773+
assert_eq!(
774+
dialog.scroll_offset, 0,
775+
"scroll should be 0 when viewport larger than content"
776+
);
770777
assert!(dialog.scroll_offset <= max_offset);
771778
}
772779

@@ -809,7 +816,10 @@ fn wrap_around_from_last_to_first_adjusts_scroll() {
809816
dialog.move_base(1);
810817

811818
assert_eq!(dialog.base_selected, 0);
812-
assert_eq!(dialog.scroll_offset, 0, "scroll should reset to top after wrap-around");
819+
assert_eq!(
820+
dialog.scroll_offset, 0,
821+
"scroll should reset to top after wrap-around"
822+
);
813823
}
814824

815825
#[test]
@@ -823,12 +833,13 @@ fn scroll_with_multiple_groups() {
823833
let dialog = dialog::CreateDialog::new(&branches, &worktrees, Some("main"));
824834

825835
// Verify flat_lines includes both groups
826-
let has_branch_header = dialog.flat_lines.iter().any(|line| {
827-
matches!(line, dialog::LineType::GroupHeader { title } if title == "Branches")
828-
});
829-
let has_worktree_header = dialog.flat_lines.iter().any(|line| {
830-
matches!(line, dialog::LineType::GroupHeader { title } if title == "Worktrees")
831-
});
836+
let has_branch_header = dialog
837+
.flat_lines
838+
.iter()
839+
.any(|line| matches!(line, dialog::LineType::GroupHeader { title } if title == "Branches"));
840+
let has_worktree_header = dialog.flat_lines.iter().any(
841+
|line| matches!(line, dialog::LineType::GroupHeader { title } if title == "Worktrees"),
842+
);
832843

833844
assert!(has_branch_header, "should have Branches header");
834845
assert!(has_worktree_header, "should have Worktrees header");

0 commit comments

Comments
 (0)