From f6dad0e9cea84246548ba3056221b9fb8f0ab981 Mon Sep 17 00:00:00 2001 From: Giacomo Cusinato <7659518+giacomocusinato@users.noreply.github.com> Date: Fri, 4 Apr 2025 00:06:41 +0900 Subject: [PATCH] fix: prevent `OutputWidget` to gain focus when updated --- .../browser/theia/core/application-shell.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arduino-ide-extension/src/browser/theia/core/application-shell.ts b/arduino-ide-extension/src/browser/theia/core/application-shell.ts index 379fb0ff5..82867adaa 100644 --- a/arduino-ide-extension/src/browser/theia/core/application-shell.ts +++ b/arduino-ide-extension/src/browser/theia/core/application-shell.ts @@ -13,6 +13,8 @@ import { MessageService } from '@theia/core/lib/common/message-service'; import { inject, injectable } from '@theia/core/shared/inversify'; import { ApplicationConnectionStatusContribution } from './connection-status-service'; import { ToolbarAwareTabBar } from './tab-bars'; +import { find } from '@theia/core/shared/@phosphor/algorithm'; +import { OutputWidget } from '@theia/output/lib/browser/output-widget'; @injectable() export class ApplicationShell extends TheiaApplicationShell { @@ -48,6 +50,38 @@ export class ApplicationShell extends TheiaApplicationShell { return super.addWidget(widget, { ...options, ref }); } + override doRevealWidget(id: string): Widget | undefined { + let widget = find(this.mainPanel.widgets(), (w) => w.id === id); + if (!widget) { + widget = find(this.bottomPanel.widgets(), (w) => w.id === id); + if (widget) { + this.expandBottomPanel(); + } + } + if (widget) { + const tabBar = this.getTabBarFor(widget); + if (tabBar) { + tabBar.currentTitle = widget.title; + } + } + if (!widget) { + widget = this.leftPanelHandler.expand(id); + } + if (!widget) { + widget = this.rightPanelHandler.expand(id); + } + if (widget) { + // Prevent focusing the output widget when is updated + // See https://github.com/arduino/arduino-ide/issues/2679 + if (!(widget instanceof OutputWidget)) { + this.windowService.focus(); + } + return widget; + } else { + return this.secondaryWindowHandler.revealWidget(id); + } + } + override handleEvent(): boolean { // NOOP, dragging has been disabled return false;