Skip to content

Commit

Permalink
Do not steal the focus when showing the channels
Browse files Browse the repository at this point in the history
  • Loading branch information
akshita31 committed Jan 28, 2019
1 parent e053a78 commit 885c103
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 27 deletions.
4 changes: 1 addition & 3 deletions src/observers/CsharpChannelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/observers/DotnetChannelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class DotNetChannelObserver extends BaseChannelObserver {
switch (event.constructor.name) {
case CommandDotNetRestoreStart.name:
this.clearChannel();
this.showChannel();
this.showChannel(true);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/observers/DotnetTestChannelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/observers/OmnisharpChannelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 2 additions & 17 deletions test/unitTests/logging/CsharpChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 7 additions & 2 deletions test/unitTests/logging/DotnetTestChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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;
});
});
});
10 changes: 8 additions & 2 deletions test/unitTests/logging/OmnisharpChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
});
});
Expand All @@ -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;
});
});

Expand Down

0 comments on commit 885c103

Please sign in to comment.