AMythicDev/minus

Calling page_all() twice panics

jrb0001 opened this issue · 3 comments

Describe the bug
It is currently not possible to show a second pager after the first (static) one finished.

To Reproduce

use minus::error::MinusError;

fn main() -> Result<(), MinusError> {
    for _ in 0..2 {
        let output = minus::Pager::new();

        output.set_exit_strategy(minus::ExitStrategy::PagerQuit)?;

        for i in 0..=100 {
            output.push_str(&format!("{}\n", i))?;
        }

        minus::page_all(output)?;
        }
    Ok(())
}

Expected behavior
It is possible to show many pagers sequentially.

Desktop:

  • OS: Debian 11 on WSL 1 on win11
  • Terminal: IntelliJ and MobaXterm
  • Shell: none and bash
  • 5.0.5 and main branch

Additional context
The changes from #82 are not complete. There is still one break each in the static/dynamic match which doesn't reset RUNMODE.

On the main branch, adding the missing reset leads to a deadlock. I think the dereferenced MutexGuard from the match is kept until the end of the match block. I didn't continue here because I ran into scrolling issues (#86).

Is there a reason why you need a Mutex? Otherwise atomics (for example crossbeam_utils::atomicAtomicCell) would be much easier to use for this.

There are some extra break lines that got there probably because of some merge conflicts.

Makes sense, but I still had to move the locking out of the match. PR will follow after I verified it in my application.

I actually didn't knew about crossbeam_utils::atomics::AtomicCell so I just went ahead with parking_lot since I also needed to used it in other places. I will consider it in later phases.