Update breadcrumbs when workspace folders update#154616
Conversation
jrieken
left a comment
There was a problem hiding this comment.
The change overall looks good but it should be done not inn the view but in the model, e.g BreadcrumbsModel. It should listen to the workspace change and trigger its change event
|
Thanks @jrieken - I've updated it - can you have a look before I start looking at the tests? |
| } | ||
|
|
||
| notifyWorkspaceFoldersChanges(): void { | ||
| if (this.recomputeOnWorkspaceFolderChange) { |
There was a problem hiding this comment.
I had a simpler implementation, but there was a bug where the path (dark grey label next to the root folder name) would flash in the explorer view during the manual test.
The issue was explorerViewer.ts is calling setResource instead of setFile, which also means it doesn't pass the option hidePath even though its behaviour is hidePath: true.
As there's so many users of IResourceLabel, I think this change is the safest way, even though the code is a bit messy imo.
There was a problem hiding this comment.
I would prefer the "not messy" solution.
There was a problem hiding this comment.
how about this way? (new commits on PR)
bpasero
left a comment
There was a problem hiding this comment.
Not liking the changes in labels.ts, I find recomputeOnWorkspaceFolderChange strange. Can we not somehow figure out if an update is needed when a transition happens into workspace? Isn't that like the only time we want to update?
|
|
||
| this.label = label; | ||
| this.options = options; | ||
| this.recomputeOnWorkspaceFolderChange = recomputeOnWorkspaceFolderChange; |
|
@bpasero the case is that the root folder name changes in the workspace, which can happen by editing the workspace file. |
bpasero
left a comment
There was a problem hiding this comment.
Thanks, but I am still not so happy: now we seem to be overwriting the name of a label to be the workspace folder name, but shouldnt that be something only the user of the label set? Isnt the label service typically the driver of a label name?
My worry is that someone sets a name to a label and now gets overwritten by the name of the workspace folder.
What is the actual issue to solve here? Can we not listen in breadcrumbs and update when workspaces change?
|
Well, name can be set in three ways - consumer of label service calls In this case, "consumer of labels" is "breadcrumbs" and it calls The best encapsulation is, the state ( Without this encapsulation, basically Here's the code from breadcrumbs:
Equality of each breadcrumb for calculating the common prefix is purely by URI - Rendering the new breadcrumbs is by So if label service doesn't listen to So, let's continue with the label service maintaining the state To prevent accidental updates from the I still prefer the original version as it expresses the intent most clearly. Label service set |
|
@r3m0t yeah I get it now, your previous change was nicer in that regard. I updated it a bit, please see: https://gist.github.com/bpasero/53ec674e2d6e0f11237212c87073f994 If you ok with my version and it fixes the issue (I verified it), please add it to the PR. I tried to align things a bit with how we do it in other places in that file. |
|
Thanks @bpasero , did you mean to check the value of computedWorkspaceFolderLabel in notifyWorkspaceFoldersChanges ? In your current version, it looks like you're only checking the type. It also needs to be added to clear() method. I will get to this in the next few days. |
|
Yeah feel free to further tweak it, thanks! |
This PR fixes #154615
Test plan at #154615