chore: remove unnecessary panic!s

This commit is contained in:
Nik Revenco 2025-03-19 00:04:54 +00:00
parent 1782c35860
commit ff60198273

View file

@ -76,20 +76,17 @@ pub(super) fn register_hooks(handlers: &Handlers) {
let tx = handlers.blame.clone(); let tx = handlers.blame.clone();
register_hook!(move |event: &mut PostCommand<'_, '_>| { register_hook!(move |event: &mut PostCommand<'_, '_>| {
if event.cx.editor.config().vcs.blame { if event.cx.editor.config().vcs.blame {
let blame_enabled = event.cx.editor.config().vcs.blame;
let (view, doc) = current!(event.cx.editor); let (view, doc) = current!(event.cx.editor);
let text = doc.text(); let text = doc.text();
let selection = doc.selection(view.id); let selection = doc.selection(view.id);
let Some(file) = doc.path() else { let Some(file) = doc.path() else {
panic!(); return Ok(());
}; };
if !blame_enabled {
panic!();
}
let cursor_lin = text.char_to_line(selection.primary().cursor(doc.text().slice(..))); let Ok(cursor_line) = TryInto::<u32>::try_into(
let Ok(cursor_line) = TryInto::<u32>::try_into(cursor_lin) else { text.char_to_line(selection.primary().cursor(doc.text().slice(..))),
panic!(); ) else {
return Ok(());
}; };
send_blocking( send_blocking(