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

Explore rendering code as a flat list #230

Open
alvarlagerlof opened this issue Aug 13, 2023 · 0 comments
Open

Explore rendering code as a flat list #230

alvarlagerlof opened this issue Aug 13, 2023 · 0 comments

Comments

@alvarlagerlof
Copy link
Owner

Problem

Currently, the code renderer currently makes use of DOM nesting for indentation. At specific points, Nodes get left margin, and all of their children inherits that, and may also add more margin, and so on.

image

x-ref: https://twitter.com/alvarlagerlof/status/1689075800694272000

This may be an inefficient way to render the code though. Each indentation layer creates at least one new DOM element, containing a lot of children. So the minimum number of elements is not just one per line of code, but one per line of code + one per indentation change.

Proposed solution

Since the indentation is already calculated based on the structure of the code, it should be possible to calculate it in JS and render the whole tree as a flat list, with calculated indentation accumulated at the beginning of each element.

This would probably easily allow windowing as well, to only render the part of the tree that is visible in the viewport.

The expand/collapse functionality of the codebase would probably suffer though, I'm not sure what to do with that right now.

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

No branches or pull requests

1 participant