Skip to content

Commit 5aae800

Browse files
author
Akos Kitta
committed
when switching serial monitor on/off
open/dispose the monitor widget instead of toggling it. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent a2b3d9b commit 5aae800

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

arduino-ide-extension/src/browser/monitor/monitor-view-contribution.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,23 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
8787
}
8888
});
8989
if (this.toggleCommand) {
90-
commands.registerCommand(this.toggleCommand, {
91-
execute: () => this.openView({
92-
toggle: true,
93-
activate: true
94-
})
95-
});
96-
const toolbarCmd = {
97-
id: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR
98-
}
99-
commands.registerCommand(toolbarCmd, {
90+
commands.registerCommand(this.toggleCommand, { execute: () => this.toggle() });
91+
commands.registerCommand({ id: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR }, {
10092
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right',
101-
execute: () => this.openView({
102-
toggle: true,
103-
activate: true
104-
})
93+
execute: () => this.toggle()
10594
});
10695
}
10796
}
10897

98+
protected async toggle(): Promise<void> {
99+
const widget = this.tryGetWidget();
100+
if (widget) {
101+
widget.dispose();
102+
} else {
103+
await this.openView({ activate: true, reveal: true });
104+
}
105+
}
106+
109107
protected renderAutoScrollButton(): React.ReactNode {
110108
return <React.Fragment key='autoscroll-toolbar-item'>
111109
<div

0 commit comments

Comments
 (0)