LeaVerou / htest

Declarative, boilerplate-free unit testing
https://htest.dev/
MIT License
19 stars 3 forks source link

Keyboard shortcuts for interactive CLI #37

Closed DmitrySharabin closed 5 months ago

DmitrySharabin commented 6 months ago

Initially, this came from Lea's proposal where Lea suggested adding two new keyboard shortcuts:

I would also add:

And one more thing that might enhance the current behavior of : press ones — collapse the current node (the current behavior), second press — collapse the parent node, third press — collapse the grandparent node, etc. This should increase speed a bit when working with the results.

Thoughts?

LeaVerou commented 6 months ago

I love it. Where do the shortcuts come from? Have you found any established conventions in other collapsible trees?

DmitrySharabin commented 6 months ago

Where do the shortcuts come from? Have you found any established conventions in other collapsible trees?

Unfortunately, I couldn't find any established conventional shortcuts when working with collapsible trees except the one that operation systems provide for file/folder trees.

They use arrow keys to navigate the tree one level. The Alt key modifies the default behavior, such as going to the first or last node in the current subtree. Combined with Ctrl and Alt, the arrow keys can be used to perform actions on the level of the whole tree (where applicable).

Using the Shift key to navigate to the top or bottom was not a good idea—in general, the Shift key is used to select consequent nodes (files/folders).

So, I would end up with the following shortcuts:

LeaVerou commented 6 months ago

No strong opinion on the modifiers besides that I agree you should need two modifiers for the expand/collapse all behavior. Given that we don't have a selection concept, I think it's fine to use Shift. Or even Ctrl. Not sure I'd try Alt if I were to guess what shortcut might work, but I don't have a strong opinion against it. Just make sure that the code makes it easy to change in the future, and please document these shortcuts in the docs about how that test runner works.