compose: don't unwrap if pseudoterminal creation fails

Show error notification instead.
pull/144/head
Manos Pitsidianakis 2 years ago
parent dc5afa13db
commit e6d6e1f588

@ -1642,23 +1642,30 @@ impl Component for Composer {
); );
if *account_settings!(context[self.account_hash].composing.embed) { if *account_settings!(context[self.account_hash].composing.embed) {
self.embed = Some(EmbedStatus::Running( match crate::terminal::embed::create_pty(
crate::terminal::embed::create_pty( width!(self.embed_area),
width!(self.embed_area), height!(self.embed_area),
height!(self.embed_area), [editor, f.path().display().to_string()].join(" "),
[editor, f.path().display().to_string()].join(" "), ) {
) Ok(embed) => {
.unwrap(), self.embed = Some(EmbedStatus::Running(embed, f));
f, self.set_dirty(true);
)); context
self.set_dirty(true); .replies
context .push_back(UIEvent::ChangeMode(UIMode::Embed));
.replies context.replies.push_back(UIEvent::Fork(ForkType::Embed(
.push_back(UIEvent::ChangeMode(UIMode::Embed)); self.embed.as_ref().unwrap().lock().unwrap().child_pid,
context.replies.push_back(UIEvent::Fork(ForkType::Embed( )));
self.embed.as_ref().unwrap().lock().unwrap().child_pid, self.mode = ViewMode::Embed;
))); }
self.mode = ViewMode::Embed; Err(err) => {
context.replies.push_back(UIEvent::Notification(
Some(format!("Failed to create pseudoterminal: {}", err)),
err.to_string(),
Some(NotificationType::Error(melib::error::ErrorKind::External)),
));
}
}
return true; return true;
} }
/* Kill input thread so that spawned command can be sole receiver of stdin */ /* Kill input thread so that spawned command can be sole receiver of stdin */

Loading…
Cancel
Save