Skip to content

Commit 9645901

Browse files
committed
🐛 fix: when empty, don't panic with []
1 parent 29fbfc9 commit 9645901

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/popups/conventional_commit.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -591,20 +591,28 @@ impl ConventionalCommitPopup {
591591
}
592592
#[cfg(feature = "gitmoji")]
593593
{
594-
let (emoji, short_msg, _) = self.query_results_more_info
595-
[self.selected_index]
596-
.strings();
597-
self.queue.push(crate::queue::InternalEvent::OpenCommit);
598-
self.queue.push(
599-
crate::queue::InternalEvent::AddCommitMessage(
600-
format!(
601-
"{emoji} {commit_type}{}{}{short_msg}",
602-
if self.is_breaking { "!" } else { "" },
603-
if short_msg.is_empty() { "" } else { ": " },
594+
if let Some((emoji, short_msg, _)) = self
595+
.query_results_more_info
596+
.get(self.selected_index)
597+
.map(|more_info| more_info.strings())
598+
{
599+
self.queue
600+
.push(crate::queue::InternalEvent::OpenCommit);
601+
self.queue.push(
602+
crate::queue::InternalEvent::AddCommitMessage(
603+
format!(
604+
"{emoji} {commit_type}{}{}{short_msg}",
605+
if self.is_breaking { "!" } else { "" },
606+
if short_msg.is_empty() {
607+
""
608+
} else {
609+
": "
610+
},
611+
),
604612
),
605-
),
606-
);
607-
self.hide();
613+
);
614+
self.hide();
615+
}
608616
}
609617
}
610618

0 commit comments

Comments
 (0)