AMythicDev / minus

An asynchronous, runtime data feedable terminal paging library for Rust
https://crates.io/crates/minus/
Apache License 2.0
317 stars 23 forks source link

Fix order of mode restoration #136

Closed martindisch closed 5 months ago

martindisch commented 5 months ago

While using Jujutsu on Windows 10/11 in PowerShell, I discovered a bug that's very easy to fix. Whenever I enter the pager (for example with jj log) for the second time in a row, it fails to properly repaint. That's because the order of operations in term::cleanup is not exactly the inverse of term::setup. The problem is that the EnableMouseCapture command in crossterm stores the current mode and DisableMouseCapture restores it, so in effect it used to restore raw mode (which was enabled before enabling mouse capture) during cleanup after having disabled it.

I only observed this behavior in PowerShell so far, not cmd.exe. Maybe only PowerShell respects these accidentally mixed up mode settings between invocations while cmd.exe restores the original mode somehow.

AMythicDev commented 5 months ago

It most likely is a Windows-specific problem since I never came across this in all the Linux terminals that I tested minus on. Anyways Merging this. I will drop a patch release for this later this week.

martindisch commented 5 months ago

Thank you for the quick turnaround, much appreciated.