visidata
visidata copied to clipboard
visidata crashes when Windows Terminal is resized
Small description if visidata (running via pipx install in Windows Terminal via PowerShell) is open and I enlarge or reduce the window horizontally, it will crash with no error. When I reopen the file, the columns are out of alignment.
Expected result Visidata doesn't crash and shows more or fewer columns based on horizontal enlarge or reduce
Actual result with screenshot
If you get an unexpected error, please include the full stack trace that you get with Ctrl-E
.
Before horizontal enlarge
After horizontal enlarge Back at the command prompt with no error shown
Re-open file after horizontal enlarge
Before horizontal reduce
Reopen file after horizontal reduce
Steps to reproduce with sample data and a .vd
Please attach the commandlog (saved with Ctrl-D
) to show the steps that led to the issue.
See here for more details.
I have tried multiple files. You should be able to repro with any file.
- Open file.
- With the mouse, grab the right edge of the window to enlarge or reduce it.
Additional context Please include the version of VisiData. package visidata 2.9.1, installed using Python 3.10.4
Windows 11 Microsoft.WindowsTerminal 1.14.1963.0 PowerShell 7.2.5 (Also repros with Command Prompt, but it opens in Windows Terminal host as well)
Hi @seajhawk, does Ctrl+L
fix the display for you after resizing?
I should have mentioned it, but no, that didn't work. I could see the screen refresh, but the columns didn't change.
I once had an issue related to window resize on Linux. Not sure if this would help: https://github.com/saulpw/visidata/issues/280
@seajhawk Can you try @frosencrantz 's solution and see if it fixes your problem?
@VisiData.api
def fix_size(vd):
(c,r) = os.get_terminal_size()
curses.resizeterm(r,c)
BaseSheet.addCommand('zZ', 'real-resize', 'fix_size()')
I'm also running into the same issue as OP. Similar setup (pipx on windows 10 using visidata 2.9.1 and python 3.8.12)
I attempted to add your commands to visidatarc and I still get a crash when resizing the window on windows terminal/command prompt.
Hi @georgebreen, when you say "crash", do you mean that you had to restart your computer? Or the program made a loud crashing noise? Could you still use any commands?
Hi @saulpw, apologies for not specifying.
I have two scenarios that cause some issues.
To replicate scenario 1:
- I open a fresh command prompt as a window
- Open visidata via 'visidata'
- Maximize the window
At this point I'm kicked back to the terminal without warning.
Another scenario which might be interesting:
- I open a fresh command prompt and maximize it.
- Open visidata via 'visidata'
- "un-maximize" the window
At this point, the terminal is still receiving commands, but CTRL+L to refresh does not display anything.
However, if I maximize the window once again, and scroll wheel up, it seems to continue working but the UI element that has File Edit View etc is missing on all frames.
If I try to use the real-refresh command you posted above, I get the following error.
Traceback (most recent call last):
File "C:\Users\GeorgeB\.local\pipx\venvs\visidata\lib\site-packages\visidata\basesheet.py", line 169, in execCommand
escaped = super().execCommand2(cmd, vdglobals=vdglobals)
File "C:\Users\GeorgeB\.local\pipx\venvs\visidata\lib\site-packages\visidata\basesheet.py", line 69, in execCommand2
exec(code, vdglobals, LazyChainMap(vd, self))
File "real-resize", line 1, in <module>
'VisiData: a curses interface for exploring and arranging tabular data'
File "C:\Users\GeorgeB\.visidatarc", line 4, in fix_size
curses.resizeterm(r,c)
AttributeError: module 'curses' has no attribute 'resizeterm'
Hopefully this all helps. This is a wonderful tool.
According to the windows-curses
package, it's actually resize_term
on Windows. Try using curses.resize_term(0,0)
instead. Otherwise I'm sorry, I'm out of ideas :/
Unfortunately that did not fix the issue, but thank you for the suggestion.
I did check the windows application event log and found that it does show curses as the faulting module (curses.cp38-win_amd64.pyd).
It is strange because every other part of the program seems to work just fine, but after researching this issue I've seen that there's appears to be a long history of this bug and the windows builds of curses.
I also confirmed that this behavior happens on the newest stable release of python (3.10.6) on windows 11 with visidata installed NOT using pipx.
I can send you the crash report privately if you believe that will provide some insight.
I don't think it'll mean anything to me, unfortunately. It does sound like it's a problem external to VisiData and shared by other programs, so if you find a workaround, please let us know and we can apply it.
I had the opportunity to chat with a couple of Python Core Devs and they recommended switching from curses to Rich/Textualize.
I don't know what how much work that entails, or if there are features VisiData needs that they don't support, but that was the advice.
Thanks, @seajhawk. That would be a net negative for VisiData at the moment; as far as I know, Textual doesn't even support the alternate screen yet. But we're discussing possibilities here: https://github.com/saulpw/visidata/discussions/1412#discussioncomment-3453269
From the looks of this, we are not going to be making further progress on this issue. Please feel free to add any additional bug reports or notes on this error.
Kondo'd.