Skip to content

Commit

Permalink
Merge pull request #210 from mfontanini/present-mode-crash
Browse files Browse the repository at this point in the history
Don't crash in present mode
  • Loading branch information
mfontanini authored Feb 17, 2024
2 parents 7fbe67e + 5c91fb0 commit cc08314
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/presenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a> Presenter<'a> {
/// Run a presentation.
pub fn present(mut self, path: &Path) -> Result<(), PresentationError> {
self.state = PresenterState::Presenting(Presentation::from(vec![]));
self.try_reload(path);
self.try_reload(path, true);

let mut drawer =
TerminalDrawer::new(io::stdout(), self.image_printer.clone(), self.options.font_size_fallback)?;
Expand All @@ -96,7 +96,7 @@ impl<'a> Presenter<'a> {
match self.apply_command(command) {
CommandSideEffect::Exit => return Ok(()),
CommandSideEffect::Reload => {
self.try_reload(path);
self.try_reload(path, false);
break;
}
CommandSideEffect::Redraw => {
Expand Down Expand Up @@ -208,8 +208,8 @@ impl<'a> Presenter<'a> {
if needs_redraw { CommandSideEffect::Redraw } else { CommandSideEffect::None }
}

fn try_reload(&mut self, path: &Path) {
if matches!(self.options.mode, PresentMode::Presentation) {
fn try_reload(&mut self, path: &Path, force: bool) {
if matches!(self.options.mode, PresentMode::Presentation) && !force {
return;
}
self.slides_with_pending_widgets.clear();
Expand Down

0 comments on commit cc08314

Please sign in to comment.