Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmdlog] sheets created with no keypresses show errors #2293

Closed
midichef opened this issue Feb 4, 2024 · 3 comments · Fixed by #2307
Closed

[cmdlog] sheets created with no keypresses show errors #2293

midichef opened this issue Feb 4, 2024 · 3 comments · Fixed by #2307

Comments

@midichef
Copy link
Contributor

midichef commented Feb 4, 2024

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:

return self.cmdlog_sheet.rows[0].keystrokes

@midichef midichef added the bug label Feb 4, 2024
@midichef midichef changed the title [cmdlog] shortcut() returns None [cmdlog] sheets created with no keypresses show errors Feb 9, 2024
@midichef
Copy link
Contributor Author

midichef commented Feb 9, 2024

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.

return str(vd.allSheets.index(self)+1)

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.

@midichef
Copy link
Contributor Author

midichef commented Feb 9, 2024

As a secondary issue, I wonder if

return self.cmdlog_sheet.rows[0].keystrokes

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?

@saulpw
Copy link
Owner

saulpw commented Feb 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants