Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While using Jujutsu on Windows 10/11 in PowerShell, I discovered a bug that took me forever to find but was very easy to fix. Whenever I enter the scm-record view (for example with
jj diffedit
) for the second time in a row, it fails to properly repaint and finally errors out with "Initial console modes not set" from the underlying crossterm.In order to paint the view,
ui::set_up_crossterm
will first enable raw mode and then mouse capture. Once done,ui::clean_up_crossterm
disables raw mode and then mouse capture. The problem is that theEnableMouseCapture
command in crossterm stores the current mode andDisableMouseCapture
restores it.This means with this order of operations
the disable mouse capture call will re-enable the stored raw mode just after it was supposed to be disabled. Upon entering scm-record for the second time, raw mode is still enabled, which means it will skip properly initializing everything.
I only observed this behavior in PowerShell so far, not
cmd.exe
. Maybe only PowerShell respects these accidentally mixed up mode settings between invocations ofjj
whilecmd.exe
restores the original mode somehow.The fix was simply to make the whole dance symmetrical, meaning
That's what I did in the first commit. Then I realized that enabling mouse capture in crossterm actually already sets the mode to something that satisfies the conditions for being raw mode. Therefore I think it's not necessary to set raw mode ourselves and I removed it completely in the second commit. Feel free to drop that in case there's a reason for it, both approaches solve the issue for me.