Skip to content

Commit

Permalink
Add output.showQuietly to stop extensions activating Output view (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed Feb 14, 2024
1 parent 4f2ff19 commit 234e543
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
default: true,
scope: ConfigurationScope.WINDOW,
tags: ['output']
},
'output.showQuietly': {
type: 'boolean',
description: nls.localize('output.showQuietly', "When an extension requests an output channel to be shown, use a silent notification instead of activating Output view."),
default: false,
scope: ConfigurationScope.WINDOW,
tags: ['output']
}
}
});
16 changes: 15 additions & 1 deletion src/vs/workbench/contrib/output/browser/outputServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
Expand All @@ -21,6 +22,8 @@ import { OutputViewPane } from 'vs/workbench/contrib/output/browser/outputView';
import { IOutputChannelModelService } from 'vs/workbench/contrib/output/common/outputChannelModelService';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, NotificationPriority, Severity } from 'vs/platform/notification/common/notification';

const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';

Expand Down Expand Up @@ -83,6 +86,8 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@IViewsService private readonly viewsService: IViewsService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@INotificationService private readonly notificationService: INotificationService,
) {
super();
this.activeChannelIdInStorage = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, '');
Expand Down Expand Up @@ -126,12 +131,21 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
return null;
}

async showChannel(id: string, preserveFocus?: boolean): Promise<void> {
async showChannel(id: string, preserveFocus?: boolean, force?: boolean): Promise<void> {
const channel = this.getChannel(id);
if (this.activeChannel?.id !== channel?.id) {
this.setActiveChannel(channel);
this._onActiveOutputChannel.fire(id);
}
if (channel && !force && !this.viewsService.isViewVisible(OUTPUT_VIEW_ID) && this.configurationService.getValue('output.showQuietly')) {
this.notificationService.prompt(
Severity.Info,
nls.localize('output.showQuietly', "Output channel '{0}' requested your attention", channel.label),
[{ label: nls.localize('output.showQuietly.show', "Show Output"), run: () => this.showChannel(channel.id, preserveFocus, true) }],
{ priority: NotificationPriority.SILENT }
);
return;
}
const outputView = await this.viewsService.openView<OutputViewPane>(OUTPUT_VIEW_ID, !preserveFocus);
if (outputView && channel) {
outputView.showChannel(channel, !!preserveFocus);
Expand Down

0 comments on commit 234e543

Please sign in to comment.