[cmdlog] sheets created with no keypresses show errors
Closed this issue · 3 comments
Small description
clicking on dir_hidden
in the DirSheet guide raises an exception
Actual result with screenshot
File "/home/midichef/.local/lib/python3.10/site-packages/visidata/statusbar.py", line 56, in sheetlist
if len(vs.shortcut) == 1:
TypeError: object of type 'NoneType' has no len()
Steps to reproduce with sample data and a .vd
vd .
, navigate to filename
column to bring the DirSheet guide up, click on dir_hidden
Additional context
visidata 3.1dev
It looks like vs.shortcut is None
because some code for shortcut()
is obsolete, where it checks cmdlog.rows[0].keystrokes
:
Line 415 in aa9d261
Okay I've got a clearer idea of exactly when this happens. It's when you create a sheet without using keystrokes. Like a command started by exec-command
, or a help menubar entry, or clicking a statusbar link. The sheet has to have precious == False
, like a HelpSheet or OptionsSheet. So. running exec-longname
and then choosing help-commands
.
Line 412 in c702c35
Because the sheet isn't precious, it can't be found in
vd.allSheets
, so the command log is searched for keystrokes. But there are no keystrokes because the action that triggered the command wasn't a keypress.As a secondary issue, I wonder if
Line 417 in c702c35
has a remaining problem, when it uses
rows[0]
. It assumes the first row of the command log is the one that created the sheet. But they're usually set-options
commands. (This same assumption caused a problem with undo in #2244.) It seems like that may cause an error.
I haven't yet found a case it does. But before I dig deeper, what is this shortcut code for? What's an example where a keystroke from the command log can be thought of as a shortcut?
What is this shortcut code for? What's an example where a keystroke from the command log can be thought of as a shortcut?
The shortcut shown on the status bar before the sheetname: 1›sample
. For regular sheets, it's assigned; the intention is that if you opened a non-precious sheet, the "shortcut" would be the key you used to open it, like C
for the columns sheet or O
for the options sheet. But this usage was disabled (when Shift+C
just did not look right and I wasn't sure about it anyway), so these days the shortcut is only meaningful for precious sheets.
Thanks for looking into all this, by the way. I know this code can get pretty convoluted over time.