Skip to content

Commit e36f393

Browse files
fix: prevent OutputWidget to gain focus when updated (#2681)
1 parent 4d52bb2 commit e36f393

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

arduino-ide-extension/src/browser/theia/core/application-shell.ts

+34
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { MessageService } from '@theia/core/lib/common/message-service';
1313
import { inject, injectable } from '@theia/core/shared/inversify';
1414
import { ApplicationConnectionStatusContribution } from './connection-status-service';
1515
import { ToolbarAwareTabBar } from './tab-bars';
16+
import { find } from '@theia/core/shared/@phosphor/algorithm';
17+
import { OutputWidget } from '@theia/output/lib/browser/output-widget';
1618

1719
@injectable()
1820
export class ApplicationShell extends TheiaApplicationShell {
@@ -48,6 +50,38 @@ export class ApplicationShell extends TheiaApplicationShell {
4850
return super.addWidget(widget, { ...options, ref });
4951
}
5052

53+
override doRevealWidget(id: string): Widget | undefined {
54+
let widget = find(this.mainPanel.widgets(), (w) => w.id === id);
55+
if (!widget) {
56+
widget = find(this.bottomPanel.widgets(), (w) => w.id === id);
57+
if (widget) {
58+
this.expandBottomPanel();
59+
}
60+
}
61+
if (widget) {
62+
const tabBar = this.getTabBarFor(widget);
63+
if (tabBar) {
64+
tabBar.currentTitle = widget.title;
65+
}
66+
}
67+
if (!widget) {
68+
widget = this.leftPanelHandler.expand(id);
69+
}
70+
if (!widget) {
71+
widget = this.rightPanelHandler.expand(id);
72+
}
73+
if (widget) {
74+
// Prevent focusing the output widget when is updated
75+
// See https://github.com/arduino/arduino-ide/issues/2679
76+
if (!(widget instanceof OutputWidget)) {
77+
this.windowService.focus();
78+
}
79+
return widget;
80+
} else {
81+
return this.secondaryWindowHandler.revealWidget(id);
82+
}
83+
}
84+
5185
override handleEvent(): boolean {
5286
// NOOP, dragging has been disabled
5387
return false;

0 commit comments

Comments
 (0)