From cfba535372bcd16f069cf36f9ec5b4eddeb93604 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Mon, 28 Jan 2019 13:57:30 -0800 Subject: [PATCH] Do not steal the focus when showing the channels --- src/observers/CsharpChannelObserver.ts | 4 +--- src/observers/DotnetChannelObserver.ts | 2 +- src/observers/DotnetTestChannelObserver.ts | 2 +- src/observers/OmnisharpChannelObserver.ts | 2 +- .../logging/CsharpChannelObserver.test.ts | 19 ++----------------- .../logging/DotnetTestChannelObserver.test.ts | 9 +++++++-- .../logging/OmnisharpChannelObserver.test.ts | 10 ++++++++-- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/observers/CsharpChannelObserver.ts b/src/observers/CsharpChannelObserver.ts index 5bf265dbdd..68bc7dbd10 100644 --- a/src/observers/CsharpChannelObserver.ts +++ b/src/observers/CsharpChannelObserver.ts @@ -11,13 +11,11 @@ export class CsharpChannelObserver extends BaseChannelObserver { switch (event.constructor.name) { case PackageInstallStart.name: case IntegrityCheckFailure.name: - this.showChannel(true); - break; case InstallationFailure.name: case DebuggerNotInstalledFailure.name: case DebuggerPrerequisiteFailure.name: case ProjectJsonDeprecatedWarning.name: - this.showChannel(); + this.showChannel(true); break; } } diff --git a/src/observers/DotnetChannelObserver.ts b/src/observers/DotnetChannelObserver.ts index 7e34c0bd9f..bd975e767f 100644 --- a/src/observers/DotnetChannelObserver.ts +++ b/src/observers/DotnetChannelObserver.ts @@ -11,7 +11,7 @@ export class DotNetChannelObserver extends BaseChannelObserver { switch (event.constructor.name) { case CommandDotNetRestoreStart.name: this.clearChannel(); - this.showChannel(); + this.showChannel(true); break; } } diff --git a/src/observers/DotnetTestChannelObserver.ts b/src/observers/DotnetTestChannelObserver.ts index 503597b99f..b494d0b41c 100644 --- a/src/observers/DotnetTestChannelObserver.ts +++ b/src/observers/DotnetTestChannelObserver.ts @@ -14,7 +14,7 @@ export default class DotnetTestChannelObserver extends BaseChannelObserver { case DotNetTestsInClassRunStart.name: case DotNetTestDebugStart.name: case DotNetTestsInClassDebugStart.name: - this.showChannel(); + this.showChannel(true); break; } } diff --git a/src/observers/OmnisharpChannelObserver.ts b/src/observers/OmnisharpChannelObserver.ts index 7a5891e3ed..6bde14bbc6 100644 --- a/src/observers/OmnisharpChannelObserver.ts +++ b/src/observers/OmnisharpChannelObserver.ts @@ -13,7 +13,7 @@ export class OmnisharpChannelObserver extends BaseChannelObserver { case ShowOmniSharpChannel.name: case OmnisharpFailure.name: case OmnisharpServerOnStdErr.name: - this.showChannel(); + this.showChannel(true); break; case OmnisharpRestart.name: this.clearChannel(); diff --git a/test/unitTests/logging/CsharpChannelObserver.test.ts b/test/unitTests/logging/CsharpChannelObserver.test.ts index 9c2c88197c..c6f8229cb5 100644 --- a/test/unitTests/logging/CsharpChannelObserver.test.ts +++ b/test/unitTests/logging/CsharpChannelObserver.test.ts @@ -14,26 +14,11 @@ suite("CsharpChannelObserver", () => { new InstallationFailure("someStage", "someError"), new DebuggerNotInstalledFailure(), new DebuggerPrerequisiteFailure("some failure"), - new ProjectJsonDeprecatedWarning() - ].forEach((event: BaseEvent) => { - test(`${event.constructor.name}: Channel is shown`, () => { - let hasShown = false; - - let observer = new CsharpChannelObserver({ - ...getNullChannel(), - show: () => { hasShown = true; } - }); - - observer.post(event); - expect(hasShown).to.be.true; - }); - }); - - [ + new ProjectJsonDeprecatedWarning(), new IntegrityCheckFailure("", "", true), new PackageInstallStart() ].forEach((event: BaseEvent) => { - test(`${event.constructor.name}: Channel is shown and preserveFocus is set to true`, () => { + test(`${event.constructor.name}: Channel is shown and preserve focus is set to true`, () => { let hasShown = false; let preserveFocus = false; let observer = new CsharpChannelObserver({ diff --git a/test/unitTests/logging/DotnetTestChannelObserver.test.ts b/test/unitTests/logging/DotnetTestChannelObserver.test.ts index ee55824cd5..a34fede2c2 100644 --- a/test/unitTests/logging/DotnetTestChannelObserver.test.ts +++ b/test/unitTests/logging/DotnetTestChannelObserver.test.ts @@ -10,10 +10,14 @@ import DotnetTestChannelObserver from '../../../src/observers/DotnetTestChannelO suite("DotnetTestChannelObserver", () => { let hasShown: boolean; + let preserveFocus: boolean; let observer = new DotnetTestChannelObserver({ ...getNullChannel(), - show: () => { hasShown = true; } + show: (preserve) => { + hasShown = true; + preserveFocus = preserve; + } }); setup(() => { @@ -27,10 +31,11 @@ suite("DotnetTestChannelObserver", () => { new DotNetTestDebugStart("foo"), new DotNetTestsInClassDebugStart("someclass") ].forEach((event: BaseEvent) => { - test(`${event.constructor.name}: Channel is shown`, () => { + test(`${event.constructor.name}: Channel is shown and preserve focus is set to true`, () => { expect(hasShown).to.be.false; observer.post(event); expect(hasShown).to.be.true; + expect(preserveFocus).to.be.true; }); }); }); diff --git a/test/unitTests/logging/OmnisharpChannelObserver.test.ts b/test/unitTests/logging/OmnisharpChannelObserver.test.ts index e940e111b8..dcbb0687c0 100644 --- a/test/unitTests/logging/OmnisharpChannelObserver.test.ts +++ b/test/unitTests/logging/OmnisharpChannelObserver.test.ts @@ -11,14 +11,19 @@ suite("OmnisharpChannelObserver", () => { let hasShown: boolean; let hasCleared: boolean; + let preserveFocus: boolean; let observer: OmnisharpChannelObserver; setup(() => { hasShown = false; hasCleared = false; + preserveFocus = false; observer = new OmnisharpChannelObserver({ ...getNullChannel(), - show: () => { hasShown = true; }, + show: (preserve) => { + hasShown = true; + preserveFocus = preserve; + }, clear: () => { hasCleared = true; } }); }); @@ -28,10 +33,11 @@ suite("OmnisharpChannelObserver", () => { new ShowOmniSharpChannel(), new OmnisharpServerOnStdErr("std err") ].forEach((event: BaseEvent) => { - test(`${event.constructor.name}: Channel is shown`, () => { + test(`${event.constructor.name}: Channel is shown and preserveFocus is set to true`, () => { expect(hasShown).to.be.false; observer.post(event); expect(hasShown).to.be.true; + expect(preserveFocus).to.be.true; }); });