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

Fixed #5670: implemented "collapse all" in the Outline widget #5687

Merged
merged 1 commit into from
Aug 8, 2019

Conversation

fangnx
Copy link

@fangnx fangnx commented Jul 10, 2019

  • Added a "collapse all" toolbar item to the Outline widget.

@fangnx fangnx changed the title Fixed #5670: implemented "collapse all" in the Outline widget WIP: Fixed #5670: implemented "collapse all" in the Outline widget Jul 10, 2019
@kittaakos
Copy link
Contributor

kittaakos commented Jul 11, 2019

Yes, I know it is work in progress...

I wish we could generalize it a bit. Do we need to add all this boilerplate code for each tree view we want to collapse?

Screen Shot 2019-07-11 at 09 13 52

Perhaps we have to add a subclass for AbstractViewContribution<TW> and allow to be collapsible with an option. Indeed, TW should be a subclass of TreeWidget. Supporting this would have a great value.

@fangnx fangnx force-pushed the fnx-fix-5670 branch 3 times, most recently from 2a45799 to 8a49ae7 Compare July 12, 2019 19:20
@fangnx fangnx changed the title WIP: Fixed #5670: implemented "collapse all" in the Outline widget Fixed #5670: implemented "collapse all" in the Outline widget Jul 12, 2019
@vince-fugnitto
Copy link
Member

Glad to see that the suggestion to create a custom OutlineTreeModel works better! :)

I noticed an odd behavior when the outline-widget-tree is collapsed.

Steps to Reproduce:

  1. collapse the outline-widget-tree using the collapseAll toolbar button
  2. select a symbol at the end of the editor
  3. re-attempt to collapseAll, the editor jumps to the top

Solutions

For the following use case, I believe there are two approaches we can do to fix it:

  1. only execute collapseAll if there is at least one node that is expanded
  2. only enable the collapseAll button if there is a node that is expanded

bug

@fangnx
Copy link
Author

fangnx commented Jul 15, 2019

Glad to see that the suggestion to create a custom OutlineTreeModel works better! :)

I noticed an odd behavior when the outline-widget-tree is collapsed.

Steps to Reproduce:

  1. collapse the outline-widget-tree using the collapseAll toolbar button
  2. select a symbol at the end of the editor
  3. re-attempt to collapseAll, the editor jumps to the top

Solutions

For the following use case, I believe there are two approaches we can do to fix it:

  1. only execute collapseAll if there is at least one node that is expanded
  2. only enable the collapseAll button if there is a node that is expanded

bug

After some investigation, it seems when a symbol is selected in the editor, the selection in outline tree is not properly updated.

@fangnx fangnx force-pushed the fnx-fix-5670 branch 2 times, most recently from b84a8e6 to 7b1cf84 Compare July 15, 2019 19:36
@fangnx
Copy link
Author

fangnx commented Jul 15, 2019

@vince-fugnitto The issue with selected symbols in monaco editors has been solved. Now the collapsing action does not perform any selection, so there is no need for selecting node after it is done, which means the editor would not "move" with the collapse-all action.

@fangnx fangnx force-pushed the fnx-fix-5670 branch 2 times, most recently from 7b1cf84 to 332d3f9 Compare July 15, 2019 20:11
@vince-fugnitto
Copy link
Member

@fangnx I think someone else should also try reviewing, I helped through the development process and just want to know anyone else's feedback on the approach taken.

@vince-fugnitto vince-fugnitto requested a review from elaihau July 16, 2019 17:38
@kittaakos
Copy link
Contributor

@fangnx, are you planning to generalize the Collapse All behavior for all TreeWidgets in Theia or you consider this PR as done?

@fangnx
Copy link
Author

fangnx commented Jul 18, 2019

@fangnx, are you planning to generalize the Collapse All behavior for all TreeWidgets in Theia or you consider this PR as done?

I consider the PR as done. I think generalizing the TreeContribution should be a different PR as it requires quite a lot of refactoring.

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Refactoring the boilerplate code in the other extensions would be nice, but it should be a separate PR as @fangnx said. For now this change does what it is meant to do :)

We may fill an issue regarding the refactoring, in case we don't work on it right away.

@kittaakos are you OK with this approach?

@vince-fugnitto
Copy link
Member

@fangnx please rebase against master and resolve the conflicts of the changelog.
It still looks like its part of 0.9.0 and not 0.10.0.

@akosyakov
Copy link
Member

@vince-fugnitto @marechal-p please finish the review, code-wise it looks good to me

@vince-fugnitto
Copy link
Member

I think as an improvement we can make the icons expand and collapse perform expand and collapse without setting focus on the entire tree node.

I think the following use case can be handled better:

  1. open the file callhierarchy-context.ts and select the last outline symbol (dispose) in the outline view
  2. perform collapse-all in the outline view
  3. attempt to re-expand the top level node using the expand icon (CallHierarchyContext)

Expected: the editor stays fixed, dispose stays highlighted (similarly to VSCode)
Actual: the editor jumps to the top, CallHierarchyContext and dispose are both highlighted

@fangnx
Copy link
Author

fangnx commented Aug 2, 2019

I think as an improvement we can make the icons expand and collapse perform expand and collapse without setting focus on the entire tree node.

I think the following use case can be handled better:

  1. open the file callhierarchy-context.ts and select the last outline symbol (dispose) in the outline view
  2. perform collapse-all in the outline view
  3. attempt to re-expand the top level node using the expand icon (CallHierarchyContext)

Expected: the editor stays fixed, dispose stays highlighted (similarly to VSCode)
Actual: the editor jumps to the top, CallHierarchyContext and dispose are both highlighted

Yes, I think that can be a good improvement (useful & aligned with VS Code behaviour). Should it be a different PR? ;)

CHANGELOG.md Outdated Show resolved Hide resolved
@akosyakov akosyakov added the outline issues related to the outline label Aug 5, 2019
@vince-fugnitto
Copy link
Member

vince-fugnitto commented Aug 5, 2019

Yes, I think that can be a good improvement (useful & aligned with VS Code behaviour). Should it be a different PR? ;)

I think it can be done separately, but is a bug that two nodes are highlighted simultaneously?

this.selectNode(node);
}
}
this.selectOnExpansion(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would onExpansion make more sense?

Copy link
Member

@akosyakov akosyakov Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is naming convention for events or notification usually to start on. I prefer to give names to clarify intention. We could name handleExpansion but it does not explain what method does. I would usually then introduce 2 template methods:

  • generic tempalte method handleExpansion, so one can override it
  • and selectOnExpansion which is called by default from handleExpansion

selectOnExpansion then can be renamed to something else to clarify intention even better, i.e. selectIfAncestorOfSelected

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated ;)

@fangnx fangnx force-pushed the fnx-fix-5670 branch 2 times, most recently from a5a226d to 79353ea Compare August 6, 2019 17:37
…idget

- Added a "collapse all" toolbar item to the Outline widget.
- Created `OutlineViewTreeModel` class in order to override the default `collapseAll` function and `onExpansionChanged` event handler in the default tree model.

Signed-off-by: fangnx <naxin.fang@ericsson.com>
@akosyakov
Copy link
Member

@marechal-p please help with landing if you are fine with changes

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging.

@paul-marechal paul-marechal merged commit 66976d0 into eclipse-theia:master Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
outline issues related to the outline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants