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

[Tree] Make TreeNode an immutable Sequence to allow for walking the tree #1398

Closed
davep opened this issue Dec 19, 2022 · 4 comments · Fixed by #1495
Closed

[Tree] Make TreeNode an immutable Sequence to allow for walking the tree #1398

davep opened this issue Dec 19, 2022 · 4 comments · Fixed by #1495
Assignees
Labels
enhancement New feature or request

Comments

@davep
Copy link
Contributor

davep commented Dec 19, 2022

Especially to allow some initial "just so" setup of a Tree, but also to make it easy to write code to walk a Tree, it would be useful to have public access to the children of a TreeNode.

@davep davep added the enhancement New feature or request label Dec 19, 2022
@nitzan-shaked
Copy link
Contributor

👍 I just needed this for writing code that "focuses" the tree on a specific node, collapsing all nodes other than one specific node. In my use-case I get only the names of the nodes (labels), not the nodes themselves, along them path; so have to traverse children.

@willmcgugan
Copy link
Collaborator

Making the list public invites a few problems. A dev might expect to be able to extend, remove etc and the tree to update accordingly.

I think we should provide for the use-case of iterating children, and walking a sub-tree without exposing the list.

@willmcgugan
Copy link
Collaborator

I'm thinking perhaps we should make TreeNode a Sequence, to allow for iterating. This would allow for walking a tree while not exposing internals.

@willmcgugan willmcgugan changed the title Consider making children a public property of a TreeNode Make TreeNode a immutable Sequence to allow for walking the tree Jan 4, 2023
@willmcgugan willmcgugan changed the title Make TreeNode a immutable Sequence to allow for walking the tree [Tree] Make TreeNode a immutable Sequence to allow for walking the tree Jan 4, 2023
@davep davep changed the title [Tree] Make TreeNode a immutable Sequence to allow for walking the tree [Tree] Make TreeNode an immutable Sequence to allow for walking the tree Jan 5, 2023
@Textualize Textualize deleted a comment from github-actions bot Jan 5, 2023
@davep davep self-assigned this Jan 5, 2023
davep added a commit to davep/textual that referenced this issue Jan 5, 2023
In anticipation of satisfying Textualize#1398, this adds a generic immutable sequence
wrapper class. The idea being that it can be used to wrap up a list or
similar, that you don't want the caller to modify.

This commit aims to get the basics down for this, and also adds a minimal
set of unit tests.
davep added a commit to davep/textual that referenced this issue Jan 5, 2023
@davep davep linked a pull request Jan 5, 2023 that will close this issue
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

rodrigogiraoserrao pushed a commit that referenced this issue Jan 7, 2023
In anticipation of satisfying #1398, this adds a generic immutable sequence
wrapper class. The idea being that it can be used to wrap up a list or
similar, that you don't want the caller to modify.

This commit aims to get the basics down for this, and also adds a minimal
set of unit tests.
nitzan-shaked pushed a commit to nitzan-shaked/textual that referenced this issue Jan 10, 2023
In anticipation of satisfying Textualize#1398, this adds a generic immutable sequence
wrapper class. The idea being that it can be used to wrap up a list or
similar, that you don't want the caller to modify.

This commit aims to get the basics down for this, and also adds a minimal
set of unit tests.
nitzan-shaked pushed a commit to nitzan-shaked/textual that referenced this issue Jan 10, 2023
nitzan-shaked pushed a commit to nitzan-shaked/textual that referenced this issue Jan 10, 2023
In anticipation of satisfying Textualize#1398, this adds a generic immutable sequence
wrapper class. The idea being that it can be used to wrap up a list or
similar, that you don't want the caller to modify.

This commit aims to get the basics down for this, and also adds a minimal
set of unit tests.
nitzan-shaked pushed a commit to nitzan-shaked/textual that referenced this issue Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants