Skip to content

Commit 168f746

Browse files
committed
Adds view badge support to base models
1 parent a8b989d commit 168f746

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/views/viewBase.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
TreeViewExpansionEvent,
99
TreeViewSelectionChangeEvent,
1010
TreeViewVisibilityChangeEvent,
11+
ViewBadge,
1112
} from 'vscode';
1213
import { Disposable, EventEmitter, MarkdownString, TreeItemCollapsibleState, window } from 'vscode';
1314
import type {
@@ -213,6 +214,16 @@ export abstract class ViewBase<
213214

214215
return false;
215216
}
217+
218+
get badge(): ViewBadge | undefined {
219+
return this.tree?.badge;
220+
}
221+
set badge(value: ViewBadge | undefined) {
222+
if (this.tree != null) {
223+
this.tree.badge = value;
224+
}
225+
}
226+
216227
private _title: string | undefined;
217228
get title(): string | undefined {
218229
return this._title;

src/webviews/webviewController.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Webview, WebviewPanel, WebviewView, WindowState } from 'vscode';
1+
import type { ViewBadge, Webview, WebviewPanel, WebviewView, WindowState } from 'vscode';
22
import { Disposable, EventEmitter, Uri, ViewColumn, window, workspace } from 'vscode';
33
import { getNonce } from '@env/crypto';
44
import type { Commands, CustomEditorIds, WebviewIds, WebviewViewIds } from '../constants';
@@ -194,6 +194,17 @@ export class WebviewController<
194194
return !this._isEditor;
195195
}
196196

197+
get badge(): ViewBadge | undefined {
198+
return 'badge' in this.parent ? this.parent.badge : undefined;
199+
}
200+
set badge(value: ViewBadge | undefined) {
201+
if ('badge' in this.parent) {
202+
this.parent.badge = value;
203+
} else {
204+
throw new Error("The 'badge' property not supported on Webview parent");
205+
}
206+
}
207+
197208
private _description: string | undefined;
198209
get description(): string | undefined {
199210
if ('description' in this.parent) {

0 commit comments

Comments
 (0)