Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/features/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as vscode from 'vscode';
import { DotNetAttachItemsProviderFactory, AttachPicker, RemoteAttachPicker } from './processPicker';
import { generateAssets } from '../assets';
import { getAdapterExecutionCommand } from '../coreclr-debug/activate';
import { CommandShowOutput, CommandDotNetRestoreStart, CommandDotNetRestoreProgress, CommandDotNetRestoreSucceeded, CommandDotNetRestoreFailed } from '../omnisharp/loggingEvents';
import { ShowOmniSharpChannel, CommandDotNetRestoreStart, CommandDotNetRestoreProgress, CommandDotNetRestoreSucceeded, CommandDotNetRestoreFailed } from '../omnisharp/loggingEvents';
import { EventStream } from '../EventStream';
import { PlatformInformation } from '../platform';
import CompositeDisposable from '../CompositeDisposable';
Expand All @@ -23,7 +23,7 @@ import OptionProvider from '../observers/OptionProvider';
export default function registerCommands(server: OmniSharpServer, platformInfo: PlatformInformation, eventStream: EventStream, optionProvider: OptionProvider): CompositeDisposable {
let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server));
let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider));
let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new CommandShowOutput()));
let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel()));
let d4 = vscode.commands.registerCommand('dotnet.restore', fileName => {
if (fileName) {
dotnetRestoreForProject(server, fileName, eventStream);
Expand Down
7 changes: 5 additions & 2 deletions src/observers/OmnisharpChannelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
*--------------------------------------------------------------------------------------------*/

import { BaseChannelObserver } from "./BaseChannelObserver";
import { BaseEvent, CommandShowOutput, OmnisharpFailure } from '../omnisharp/loggingEvents';
import { BaseEvent, ShowOmniSharpChannel, OmnisharpFailure, OmnisharpRestart } from '../omnisharp/loggingEvents';

export class OmnisharpChannelObserver extends BaseChannelObserver {

public post = (event: BaseEvent) => {
switch (event.constructor.name) {
case CommandShowOutput.name:
case ShowOmniSharpChannel.name:
this.showChannel();
break;
case OmnisharpFailure.name:
this.showChannel();
break;
case OmnisharpRestart.name:
this.clearChannel();
break;
}
}
}
5 changes: 3 additions & 2 deletions src/omnisharp/loggingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class OmnisharpServerVerboseMessage extends EventWithMessage { }

export class ProjectModified implements BaseEvent { }
export class ActivationFailure implements BaseEvent { }
export class CommandShowOutput implements BaseEvent { }
export class ShowOmniSharpChannel implements BaseEvent { }
export class DebuggerNotInstalledFailure implements BaseEvent { }
export class CommandDotNetRestoreStart implements BaseEvent { }
export class InstallationSuccess implements BaseEvent { }
Expand All @@ -146,4 +146,5 @@ export class OmnisharpOnBeforeServerInstall implements BaseEvent { }
export class ActiveTextEditorChanged implements BaseEvent { }
export class OmnisharpServerOnStop implements BaseEvent { }
export class OmnisharpServerOnStart implements BaseEvent { }
export class LatestBuildDownloadStart implements BaseEvent { }
export class LatestBuildDownloadStart implements BaseEvent { }
export class OmnisharpRestart implements BaseEvent { }
1 change: 1 addition & 0 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export class OmniSharpServer {
public async restart(launchTarget: LaunchTarget = this._launchTarget): Promise<void> {
if (launchTarget) {
await this.stop();
this.eventStream.post(new ObservableEvents.OmnisharpRestart());
const options = this.optionProvider.GetLatestOptions();
await this._start(launchTarget, options);
}
Expand Down
43 changes: 33 additions & 10 deletions test/unitTests/logging/OmnisharpChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,45 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { should, expect } from 'chai';
import { expect } from 'chai';
import { getNullChannel } from '../testAssets/Fakes';
import { OmnisharpChannelObserver } from '../../../src/observers/OmnisharpChannelObserver';
import { OmnisharpFailure } from '../../../src/omnisharp/loggingEvents';
import { OmnisharpFailure, ShowOmniSharpChannel, BaseEvent, OmnisharpRestart } from '../../../src/omnisharp/loggingEvents';

suite("OmnisharpChannelObserver", () => {
suiteSetup(() => should());
test(`OmnisharpFailure: Shows the channel`, () => {
let event = new OmnisharpFailure("errorMessage", new Error("error"));
let hasShown = false;
let observer = new OmnisharpChannelObserver({

let hasShown: boolean;
let hasCleared: boolean;
let observer: OmnisharpChannelObserver;

setup(() => {
hasShown = false;
hasCleared = false;
observer = new OmnisharpChannelObserver({
...getNullChannel(),
show: () => { hasShown = true; }
show: () => { hasShown = true; },
clear: () => { hasCleared = true; }
});
});

observer.post(event);
expect(hasShown).to.be.true;
[
new OmnisharpFailure("errorMessage", new Error("error")),
new ShowOmniSharpChannel()
].forEach((event: BaseEvent) => {
test(`${event.constructor.name}: Channel is shown`, () => {
expect(hasShown).to.be.false;
observer.post(event);
expect(hasShown).to.be.true;
});
});

[
new OmnisharpRestart()
].forEach((event: BaseEvent) => {
test(`${event.constructor.name}: Channel is cleared`, () => {
expect(hasCleared).to.be.false;
observer.post(event);
expect(hasCleared).to.be.true;
});
});
});