Skip to content

Commit a360565

Browse files
committed
♻️ refactor: put next_step actions in fn
1 parent 3784a77 commit a360565

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/popups/conventional_commit.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,20 @@ impl ConventionalCommitPopup {
610610
);
611611
self.hide();
612612
}
613+
614+
fn next_step(&mut self) {
615+
self.selected_index = 0;
616+
self.is_insert = false;
617+
self.query = None;
618+
self.input.clear();
619+
self.update_query();
620+
}
613621
}
614622

615623
impl DrawableComponent for ConventionalCommitPopup {
616624
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
617625
if self.is_visible {
618-
const MAX_SIZE: (u16, u16) = (50, 20);
626+
const MAX_SIZE: (u16, u16) = (50, 25);
619627

620628
let area = ui::centered_rect_absolute(
621629
MAX_SIZE.0, MAX_SIZE.1, area,
@@ -737,12 +745,7 @@ impl Component for ConventionalCommitPopup {
737745
.cloned();
738746

739747
self.seleted_commit_type = commit.clone();
740-
self.selected_index = 0;
741-
self.is_insert = false;
742-
self.query = None;
743-
self.input.clear();
744-
745-
self.update_query();
748+
self.next_step();
746749

747750
if let Some(more_infos) =
748751
commit.as_ref().map(|c| c.more_info())
@@ -783,6 +786,7 @@ impl Component for ConventionalCommitPopup {
783786
self.query_results_type[idx]
784787
.clone(),
785788
);
789+
self.next_step();
786790
}
787791
}
788792
}
@@ -800,14 +804,11 @@ impl Component for ConventionalCommitPopup {
800804
}
801805

802806
fn hide(&mut self) {
807+
self.next_step();
803808
self.is_visible = false;
804-
self.is_insert = false;
805-
self.selected_index = 0;
806809
self.seleted_commit_type = None;
807-
self.query = None;
808810
self.query_results_type = CommitType::iter().collect_vec();
809811
self.query_results_more_info = Vec::new();
810-
self.input.clear();
811812
}
812813

813814
fn show(&mut self) -> Result<()> {

0 commit comments

Comments
 (0)