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 - no tree navigator #64793

Closed
jrieken opened this issue Dec 11, 2018 · 16 comments
Closed

tree - no tree navigator #64793

jrieken opened this issue Dec 11, 2018 · 16 comments
Assignees
Labels
feature-request Request for new features or functionality tree-widget Tree widget issues verification-needed Verification of issue is requested verified Verification succeeded

Comments

@jrieken
Copy link
Member

jrieken commented Dec 11, 2018

blocks #64727

the outline uses the tree navigator to select previous/next elements when having searched. this will be a lot more cumbersome using getNode API and navigation APIs

@joaomoreno
Copy link
Member

when having searched

Can you elaborate?

@joaomoreno joaomoreno added the under-discussion Issue is under discussion for relevance, priority, approach label Dec 11, 2018
@jrieken
Copy link
Member Author

jrieken commented Dec 11, 2018

Please look at how the outline uses the navigator API today

@joaomoreno
Copy link
Member

This is the only thing I could find: https://github.com/Microsoft/vscode/blob/dbb6f6d807f63429c0eb6913e86885f431b3832b/src/vs/editor/contrib/documentSymbols/outlineTree.ts#L271

We already discussed that you'd get expansion state preservation for free...

So, I'm guessing there's another place...?

@jrieken
Copy link
Member Author

jrieken commented Dec 11, 2018

yes, outlinepanel.ts

@joaomoreno
Copy link
Member

So, let me elaborate this for myself:

  • There are outline.focusDownHighlighted and outline.focusUpHighlighted commands which let the user focus the previous or next item.
  • The navigator is used to figure out what's the previous/next element which is an OutlineElement with a score (filter?).
  • Once you find a candidate, you focus and reveal it.

There are already focusNext and focusPrevious methods on the tree which could do the hard work for you. I think what's missing for them is a filter function which lets you control whether an element would be suitable for focusing or not. Would that work?

Is the another situation?

@jrieken
Copy link
Member Author

jrieken commented Dec 11, 2018

Yes, that would work for that usage in the outline panel. Tho, looking at how getNavigatior is used in breadcrumbs, search, etc it might not be enough

@roblourens
Copy link
Member

I am trying to reimplement the navigator (outside of the tree) but I don't think it's possible to tell whether an element is filtered out or not, is it?

@jrieken
Copy link
Member Author

jrieken commented Dec 12, 2018

I am trying to reimplement the navigator (outside of the tree) but

🤞 we aren't all doing this. @roblourens do you build your navigator for re-use please? then I can use it for breadcrumbs.

@joaomoreno joaomoreno added feature-request Request for new features or functionality tree-widget Tree widget issues and removed under-discussion Issue is under discussion for relevance, priority, approach labels Dec 12, 2018
@joaomoreno joaomoreno added this to the December 2018 milestone Dec 12, 2018
@joaomoreno
Copy link
Member

joaomoreno commented Dec 12, 2018

Since I think I haven't laid out my argument against a tree navigator, here it is: it inverts the model-view pattern by exposing a view as a model. Data flow ceases to be one directional and things become harder to reason about.

Because of being against it, I've been trying to be helpful in understanding each use case for it and attempting to provide alternatives, like I've done for outline: #64793 (comment). I'm pretty sure the same could be done for all current usages of the tree navigator, and would be willing to expose tree API to make it so. At the same time, I feel I'm wasting my time in dealing with unhelpful comments like:

Can you elaborate?

Please look at how the outline uses the navigator API today

So I basically stopped caring. I've pushed a TreeNavigator with some tests. It might not be bug free so file an issue if you hit any problems, I'll fix them asap.

You can use it in the ObjectTree by calling .navigate on it.

@roblourens Sorry if you wasted time on this attempting to create a navigator using getNode. It is definitely possible to do one, but it would be pretty cumbersome, just as the old tree navigator was.

@roblourens
Copy link
Member

No worries, thanks for making one. I understand your argument and I'm not opposed to getting rid of it in the future. Search is a very heavy user of it (more than I realized originally) and since I'm making lots of changes already, it's much easier to work with the same interface and not have to figure out how to refactor around it.

@roblourens
Copy link
Member

@jrieken note that this navigator doesn't update its indexes if the list view is modified, so be careful if you are expanding/collapsing nodes while navigating. Search can work around it by recreating the navigator from a certain element.

@joaomoreno
Copy link
Member

Yeah, I forgot the necessary warning: do not use it across tree modifications, it will definitely break.

@jrieken
Copy link
Member Author

jrieken commented Dec 13, 2018

Not looping and navigating but missing that fact that the old navigator could start at any element. It seems I now have to fast forward till the anchor element and then go bwd/fwd to the actual element

@roblourens
Copy link
Member

I added that to the navigator yesterday @jrieken

@roblourens
Copy link
Member

Oh I guess it's only in my branch. I can put it in master.

@roblourens
Copy link
Member

73d7889

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 26, 2019
@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Jan 28, 2019
@jrieken jrieken added the verified Verification succeeded label Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality tree-widget Tree widget issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants