-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[vscode] Support ViewBadge and tree/webview view badge property #12330
Conversation
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.
First reading of the code.
} | ||
set badge(badge: ViewBadge | undefined) { | ||
this._badge = badge; | ||
this.proxy.$setBadge(this.treeViewId, this._badge); |
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.
This is a potential problem: the badge
object is created by the plugin. It could contain arbitrary structures, which might no be serializable via our rpc algorithm (this has happened before 🤷) We need to copy the values like
this.proxy.$setBadge(this.treeViewId, {value: badge.value, tooltip: badge.tooltip});
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.
This is adressed in the new version, with a slight change due to badge being potentially undefined
:
this.proxy.$setBadge(this.treeViewId, badge ? { value: badge.value, tooltip: badge.tooltip } : undefined);
There may be a shorter syntax I am not aware of.
@@ -138,6 +150,38 @@ export class PluginViewWidget extends Panel implements StatefulWidget, Descripti | |||
this.onDidChangeDescriptionEmitter.fire(); | |||
} | |||
|
|||
get badge(): number | undefined { | |||
if (this._badge === undefined) { | |||
for (const w of this.widgets) { |
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.
This algorithm seems strange. Other places seem to assume that the "wrapped" widget is this.widgets[0]
. Why is the algorithm for badge
different from descritption
?
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.
That is indeed more coherent here with this.widget[0]
.
This is adressed in the new version.
this.assertNotDisposed(); | ||
if (this._badge !== badge) { | ||
this._badge = badge; | ||
this.proxy.$setBadge(this.handle, badge); |
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.
Same as above.
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.
This has been adressed also in the new version, with same adaptation due to badge
being potentially undefined
.
The "Calico Colors" example does not work reliably for me in electron, Invoking the action the first time, I see this in the back end log:
Sometimes, the update of the badge via "add color" or "clear colors" works, though. |
beda943
to
f72bf9b
Compare
@rschnekenbu it's usually a good idea to keep changes due to feedback in separate commits until we're ready to merge: it allows reviewers to see the latest changes, instead of having to re-review the whole thing. |
@tsmaeder, thanks for advice! I will add commit on top of the reviewed one starting from now. |
I sometimes get also the same issue, depending if the view is already selected or not in the tool. I have the same kind of issue on master, and I prefered not to spend too much time on debugging the vscode samples. There may be a test to add on the extension itself.
Is this working only sometimes or does it works always after the second action? I could not have any issue while testing once the second action has been triggered, the first one failing with the view visibility. I also have now an issue since rebasing on latest master (basically since pr #12326 was merged). The split icon terminal appears on all views, especially the calico color one. And the badges are hidden as soon as an action is in the toolbar. I had to patch the split command registration in order to get the badge working. |
Besides the "Split Terminal"-Problems above, the changes work fine for me. |
@rschnekenbu this one needs a rebase, as well. |
Extend BadgeWidget with tooltip support Provide support for badge on tree based views and webview views Contributed on behalf of STMicroelectronics Signed-off-by: Remi SCHNEKENBURGER <rschnekenburger@eclipsesource.com>
f72bf9b
to
e955bfe
Compare
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.
Looks good to me, now.
@rschnekenbu I guess I could: the licensing issues are not caused by this PR and they won't be fixed by it. The important thing re: licensing are releases, anyway, as far as I understand. |
What it does
Adds support for ViewBadge and badge for tree views and Webview views
Fixes #12020
Contributed on behalf of STMicroelectronics
How to test
This PR adds a badge to Tree based views and webviews contributed by extensions. Thus 2 extensions based on vscode samples are to be tested with this patch.
custom-view-samples-0.0.2.zip This one provides a tree view with 2 actions (change badge value and change tooltip value). The first one will ask for a new value, the second for a new tooltip.
calico-colors-0.0.13.zip This one slightly updates the webview view vscode extensions sample, to change the tooltip when the add color is triggered, and to remove the tooltip (set to undefined) when the clear colors is triggered.
To test, install the extensions and trigger the action:
Review checklist
Reminder for reviewers