-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add breadcrumbs bar to editor widget #6371
Conversation
@corneliusludmann please make sure you've signed an ECA https://accounts.eclipse.org/user/eca |
Currently working on it … ::-) |
@corneliusludmann could you attach few screenshots? |
Sure. This GIF shows the breadcrumbs in action: |
088c615
to
7b17c61
Compare
How can one disable them? Can we have |
|
}); | ||
|
||
// updateOutline and handleCurrentEditorChanged need to be called even when the outline view widget is closed | ||
// in order to udpate breadcrumbs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't understand it, if an editor is closed there should not be breadcrumbs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed condition does not check if an editor is open or closed it checks if the outline view is open or closed. Previously, the outline changes are propagated when the outline view is open only. Now we need the information even when the outline view is closed because the outline view is not the only one that uses this information anymore. The breadcrumbs need the information as well.
What we could do is to check whether the outline view is open OR the breadcrumbs are visible (by the preferences entry breadcrumbs.enabled
). I don't know if it is really worth it.
bind(BreadcrumbsRendererFactory).toFactory(ctx => | ||
(editor: TextEditor) => { | ||
const childContainer = ctx.container.createChild(); | ||
childContainer.bind('TextEditor').toConstantValue(editor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use a symbol, if there are duplicate extensions installed, they can pick a bogus instance by a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Why don't we reuse file and outline tree widgets to open URIs? We have already them, have to create new instances and render on click? I would also prefer if we have something like
|
Note: using Theia in the workspace Found some issues when playing with this PR:
|
Thank you for your helpful feedback.
Yes, that is a limitation I forgot to mention in the PR description. I currently working on adding the existing file tree view in the popup. I had it planned as the next evolutionary step. Sorry I didn't mention it.
That seems to be a bug in the existing outline view implementation. When you carefully observe the outline view you will see that on first click the outline is rendered without highlighting the current selection. Only after the second click the selection is highlighted. Thus, fixing this will fix this issue as well. I gonna file an issue for that if not already exist.
Seems to be another limitation I was not aware of. Consider to implement this as well.
Oh, yes, you're right. Outline breadcrumbs are not removed when there is no selection. Gonna fix this. |
7b17c61
to
3dee5ec
Compare
I refactored the code with commit 03eb644 which introduces I will squash the commits once I implemented all suggested changes. |
Done with commit 3dee5ec. I will squash the commits once I implemented all suggested changes. |
For the file tree widget, I currently working on it. For the outline tree widget it seems not possible yet because the tree is not easily reusable yet. |
Should be fixed with commit 03eb644. |
Hmm. At first, when I look at your video, the moment when the breadcrumbs appear is in sync with the highlighting of the tree item in the outline view. Therefore, I still think it is an general issue with the outline view. Second, when I try to reproduce your steps I realized that it does not have to do with a single or double click, it is just a delay. When I open an editor, click once, wait a few seconds and do a second click the breadcrumbs appear immediately (same with the highlighting of the outline tree item). Sometimes it needs more than a few seconds. However, in my tests, it is always in sync with the outline view highlighting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've started reviewing code, but then stopped after realizing that refactoring to reuse trees is not finished yet.
* Subscribe to this event emitter to be notifed when the breadcrumbs have changed. | ||
* The URI is the URI of the editor the breadcrumbs have changed for. | ||
*/ | ||
get onBreadcrumbsChange(): Event<URI> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onDidChangeBreadcrumbs
or onBreadcrumbsChanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* Notifies that the breadcrumbs for the given URI have changed and should be re-rendered. | ||
* This fires an `onBreadcrumsChange` event. | ||
*/ | ||
breadcrumbsChanges(uri: URI): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firing events should be an implementation detail, i.e. BreadcrumbsContribution
should have onDidChange
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I don't get it. But it sounds that this would make it more complicated without any substantial benefit since the breadcrumbs renderer has to subscribe to all breadcrumb contributions then.
/** | ||
* The breadcrumb type. Breadcrumbs returned by `#computeBreadcrumbs(uri)` should have this as `Breadcrumb#type`. | ||
*/ | ||
type: symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly
? the same about priority
/** | ||
* Opens a popup for the given breadcrumb at the given position. `parent` is used as the host element for the newly created popup element. | ||
*/ | ||
async openPopup(breadcrumb: Breadcrumb, position: { x: number, y: number }, parent: HTMLElement): Promise<BreadcrumbPopup | undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just open
?
import { BreadcrumbPopup } from './breadcrumb-popup'; | ||
|
||
export const BreadcrumbPopupContainerRenderer = Symbol('BreadcrumbPopupContainerRenderer'); | ||
export interface BreadcrumbPopupContainerRenderer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need interface, symbol and a class? Should not BreadcrumbPopupContainerRenderer
be enough? Please see https://github.com/eclipse-theia/theia/wiki/Coding-Guidelines#classes-over-interfaces
ab46c44
to
4f4879f
Compare
This commit adds a breadcrumbs bar to the editor widget. It shows the path to the current file and outline information as breadcrumbs. A click of breadcrumbs allows to jump to other files or to code sections. Fixes eclipse-theia#5475 Signed-off-by: Cornelius A. Ludmann <cornelius.ludmann@typefox.io>
4f4879f
to
509f04e
Compare
I updated this PR with the file tree for file breadcrumbs and a '…' breadcrumb for outline breadcrumbs. There are still some minor flaws with the outline breadcrumbs that are in sync with flaws in the outline itself. These need to be fixed in the outline implementation. (E.g. selecting a non-collapsed outline element does not collapse the tree in the outline view and does not set the correct breadcrumb.) From my point of view, this PR is ready for another review. |
|
I was looking to get a second review, But there are merge conflicts :( |
|
I was excited by this PR. Do we plan to merge it at some point or is it no-longer being considered? |
I am interested by this PR as well, but there was some unresolved and merging issues , they are not resolved yet |
I could resolve the merge conflicts and rebase the branch. However @akosyakov raised two requests that need to be implemented before merging:
Currently I do not have the time to take care of it. If someone else is willing to contribute to this work feel free to push to this branch or to fork this branch. I'm happy to provide assistance when needed. |
@corneliusludmann, my colleague @kenneth-marut-work and I were thinking of finishing this PR up, unless you were planning on returning to it? |
@colin-grant-work, unfortunately, I don't. I would be very happy if you would take over the work on this feature. |
What it does
This commit adds a breadcrumbs bar to the editor widget. It shows the path to the current file and outline information as breadcrumbs. A click of breadcrumbs allows to switch to siblings.
This fixes #5475.
How to test
Open an editor shows the breadcrumbs on top of the editor. Folders with files are clickable. A popup allows to select a file that will be opened immediately. Outline information are added to the breadcrumbs as well.
Review checklist
Reminder for reviewers