Skip to content

Commit 659906d

Browse files
authored
Merge pull request #2828 from akshita31/do_not_steal_focus
Do not steal the focus when showing the channels
2 parents 48703e5 + 7e01ae6 commit 659906d

File tree

8 files changed

+22
-27
lines changed

8 files changed

+22
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Fixed finding references to operator overloads _(Contributed by [@SirIntruder](https://github.com/SirIntruder))_ (PR: [omnisharp-roslyn#1371](https://github.com/OmniSharp/omnisharp-roslyn/pull/1371))
1919
* Improved handling of files moving on disk (PR: [omnisharp-roslyn#1368](https://github.com/OmniSharp/omnisharp-roslyn/pull/1368))
2020
* Improved detection of MSBuild when multiple instances are available _(Contributed by [@johnnyasantoss ](https://github.com/johnnyasantoss))_ (PR: [omnisharp-roslyn#1349](https://github.com/OmniSharp/omnisharp-roslyn/pull/1349))
21+
* Fixed a bug where the "OmniSharp" and "C# log" would steal the editor focus and hinder the user's development flow.(PR: [#2828](https://github.com/OmniSharp/omnisharp-vscode/pull/2828))
2122

2223
#### Debugger
2324
* Added support for set next statement. Set next statement is a feature that have been available for a long time in full Visual Studio, and this brings the feature to Visual Studio Code. This feature allows developers to change what code is executed in your program. For example, you can move the instruction pointer back to re-execute a function that you just ran so you can debug into it, or you can skip over some code that you don't want to execute. To use this feature, move your cursor to the next statement you would like to execute next, and either open the editor context menu and invoke 'Set Next Statement (.NET)', or use the keyboard shortcut of <kbd>Ctrl+Shift+F10</kbd> ([#1753](https://github.com/OmniSharp/omnisharp-vscode/issues/1753))

src/observers/CsharpChannelObserver.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ export class CsharpChannelObserver extends BaseChannelObserver {
1111
switch (event.constructor.name) {
1212
case PackageInstallStart.name:
1313
case IntegrityCheckFailure.name:
14-
this.showChannel(true);
15-
break;
1614
case InstallationFailure.name:
1715
case DebuggerNotInstalledFailure.name:
1816
case DebuggerPrerequisiteFailure.name:
1917
case ProjectJsonDeprecatedWarning.name:
20-
this.showChannel();
18+
this.showChannel(true);
2119
break;
2220
}
2321
}

src/observers/DotnetChannelObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class DotNetChannelObserver extends BaseChannelObserver {
1111
switch (event.constructor.name) {
1212
case CommandDotNetRestoreStart.name:
1313
this.clearChannel();
14-
this.showChannel();
14+
this.showChannel(true);
1515
break;
1616
}
1717
}

src/observers/DotnetTestChannelObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class DotnetTestChannelObserver extends BaseChannelObserver {
1414
case DotNetTestsInClassRunStart.name:
1515
case DotNetTestDebugStart.name:
1616
case DotNetTestsInClassDebugStart.name:
17-
this.showChannel();
17+
this.showChannel(true);
1818
break;
1919
}
2020
}

src/observers/OmnisharpChannelObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class OmnisharpChannelObserver extends BaseChannelObserver {
1313
case ShowOmniSharpChannel.name:
1414
case OmnisharpFailure.name:
1515
case OmnisharpServerOnStdErr.name:
16-
this.showChannel();
16+
this.showChannel(true);
1717
break;
1818
case OmnisharpRestart.name:
1919
this.clearChannel();

test/unitTests/logging/CsharpChannelObserver.test.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,11 @@ suite("CsharpChannelObserver", () => {
1414
new InstallationFailure("someStage", "someError"),
1515
new DebuggerNotInstalledFailure(),
1616
new DebuggerPrerequisiteFailure("some failure"),
17-
new ProjectJsonDeprecatedWarning()
18-
].forEach((event: BaseEvent) => {
19-
test(`${event.constructor.name}: Channel is shown`, () => {
20-
let hasShown = false;
21-
22-
let observer = new CsharpChannelObserver({
23-
...getNullChannel(),
24-
show: () => { hasShown = true; }
25-
});
26-
27-
observer.post(event);
28-
expect(hasShown).to.be.true;
29-
});
30-
});
31-
32-
[
17+
new ProjectJsonDeprecatedWarning(),
3318
new IntegrityCheckFailure("", "", true),
3419
new PackageInstallStart()
3520
].forEach((event: BaseEvent) => {
36-
test(`${event.constructor.name}: Channel is shown and preserveFocus is set to true`, () => {
21+
test(`${event.constructor.name}: Channel is shown and preserve focus is set to true`, () => {
3722
let hasShown = false;
3823
let preserveFocus = false;
3924
let observer = new CsharpChannelObserver({

test/unitTests/logging/DotnetTestChannelObserver.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import DotnetTestChannelObserver from '../../../src/observers/DotnetTestChannelO
1010

1111
suite("DotnetTestChannelObserver", () => {
1212
let hasShown: boolean;
13+
let preserveFocus: boolean;
1314

1415
let observer = new DotnetTestChannelObserver({
1516
...getNullChannel(),
16-
show: () => { hasShown = true; }
17+
show: (preserve) => {
18+
hasShown = true;
19+
preserveFocus = preserve;
20+
}
1721
});
1822

1923
setup(() => {
@@ -27,10 +31,11 @@ suite("DotnetTestChannelObserver", () => {
2731
new DotNetTestDebugStart("foo"),
2832
new DotNetTestsInClassDebugStart("someclass")
2933
].forEach((event: BaseEvent) => {
30-
test(`${event.constructor.name}: Channel is shown`, () => {
34+
test(`${event.constructor.name}: Channel is shown and preserve focus is set to true`, () => {
3135
expect(hasShown).to.be.false;
3236
observer.post(event);
3337
expect(hasShown).to.be.true;
38+
expect(preserveFocus).to.be.true;
3439
});
3540
});
3641
});

test/unitTests/logging/OmnisharpChannelObserver.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ suite("OmnisharpChannelObserver", () => {
1111

1212
let hasShown: boolean;
1313
let hasCleared: boolean;
14+
let preserveFocus: boolean;
1415
let observer: OmnisharpChannelObserver;
1516

1617
setup(() => {
1718
hasShown = false;
1819
hasCleared = false;
20+
preserveFocus = false;
1921
observer = new OmnisharpChannelObserver({
2022
...getNullChannel(),
21-
show: () => { hasShown = true; },
23+
show: (preserve) => {
24+
hasShown = true;
25+
preserveFocus = preserve;
26+
},
2227
clear: () => { hasCleared = true; }
2328
});
2429
});
@@ -28,10 +33,11 @@ suite("OmnisharpChannelObserver", () => {
2833
new ShowOmniSharpChannel(),
2934
new OmnisharpServerOnStdErr("std err")
3035
].forEach((event: BaseEvent) => {
31-
test(`${event.constructor.name}: Channel is shown`, () => {
36+
test(`${event.constructor.name}: Channel is shown and preserveFocus is set to true`, () => {
3237
expect(hasShown).to.be.false;
3338
observer.post(event);
3439
expect(hasShown).to.be.true;
40+
expect(preserveFocus).to.be.true;
3541
});
3642
});
3743

0 commit comments

Comments
 (0)