Skip to content

Commit 1b58747

Browse files
authored
simplify the workspace trust status bar entry (microsoft#203557)
1 parent 6be4d6c commit 1b58747

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class WorkspaceTrustRequestHandler extends Disposable implements IWorkben
222222
*/
223223
export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchContribution {
224224

225-
private readonly entryId = `status.workspaceTrust.${this.workspaceContextService.getWorkspace().id}`;
225+
private readonly entryId = `status.workspaceTrust`;
226226

227227
private readonly statusbarEntryAccessor: MutableDisposable<IStatusbarEntryAccessor>;
228228

@@ -253,7 +253,7 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
253253

254254
if (this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
255255
this.registerListeners();
256-
this.createStatusbarEntry();
256+
this.updateStatusbarEntry(this.workspaceTrustManagementService.isWorkspaceTrusted());
257257

258258
// Show modal dialog
259259
if (this.hostService.hasFocus) {
@@ -555,12 +555,6 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
555555

556556
//#region Statusbar
557557

558-
private createStatusbarEntry(): void {
559-
const entry = this.getStatusbarEntry(this.workspaceTrustManagementService.isWorkspaceTrusted());
560-
this.statusbarEntryAccessor.value = this.statusbarService.addEntry(entry, this.entryId, StatusbarAlignment.LEFT, 0.99 * Number.MAX_VALUE /* Right of remote indicator */);
561-
this.statusbarService.updateEntryVisibility(this.entryId, false);
562-
}
563-
564558
private getStatusbarEntry(trusted: boolean): IStatusbarEntry {
565559
const text = workspaceTrustToString(trusted);
566560

@@ -625,8 +619,15 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
625619
}
626620

627621
private updateStatusbarEntry(trusted: boolean): void {
628-
this.statusbarEntryAccessor.value?.update(this.getStatusbarEntry(trusted));
629-
this.statusbarService.updateEntryVisibility(this.entryId, !trusted);
622+
if (trusted && this.statusbarEntryAccessor.value) {
623+
this.statusbarEntryAccessor.clear();
624+
return;
625+
}
626+
627+
if (!trusted && !this.statusbarEntryAccessor.value) {
628+
const entry = this.getStatusbarEntry(trusted);
629+
this.statusbarEntryAccessor.value = this.statusbarService.addEntry(entry, this.entryId, StatusbarAlignment.LEFT, 0.99 * Number.MAX_VALUE /* Right of remote indicator */);
630+
}
630631
}
631632

632633
//#endregion

0 commit comments

Comments
 (0)