vscode-nbt icon indicating copy to clipboard operation
vscode-nbt copied to clipboard

feat(TreeEditor): add keyboard support - arrow key move / expand

Open John-Paul-R opened this issue 1 year ago • 0 comments

Hello, and happy Modtoberfest!

This PR adds the ability to navigate the TreeEditor with via keyboard Up,Down,Left,Right or HJKL (vim keys).

I tried to mirror vscode's file tree navigation behavior pretty closely since, well, we're in vscode. (and I think vscode's behavior here is reasonable). A known exception in this current iteration is that Down when on the last item in a container doesn't take you to the item after the container. (and Down when on the root item of a container takes you to that container's sibling, rather than entering the container (Right is used for that)). This might be worth changing, but I'm fairly happy with where this is at right now.

I tried not to restructure things too much, so I computed most of the "next item" fun on the fly, rather than modifying the core tree data structure to support it. (A new structure, or added cache, at least, might be helpful on super big objects, but I think this will be more than fast enough for the vast majority of files.)


Demo!

https://github.com/user-attachments/assets/5428d481-50ac-4704-af9e-d9e623f581b6

John-Paul-R avatar Oct 12 '24 18:10 John-Paul-R