when switching serial monitor on/off

open/dispose the monitor widget instead of toggling it.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-07-31 15:48:35 +02:00
parent a2b3d9b314
commit 5aae800a4e

View File

@ -87,25 +87,23 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
} }
}); });
if (this.toggleCommand) { if (this.toggleCommand) {
commands.registerCommand(this.toggleCommand, { commands.registerCommand(this.toggleCommand, { execute: () => this.toggle() });
execute: () => this.openView({ commands.registerCommand({ id: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR }, {
toggle: true,
activate: true
})
});
const toolbarCmd = {
id: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR
}
commands.registerCommand(toolbarCmd, {
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right', isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right',
execute: () => this.openView({ execute: () => this.toggle()
toggle: true,
activate: true
})
}); });
} }
} }
protected async toggle(): Promise<void> {
const widget = this.tryGetWidget();
if (widget) {
widget.dispose();
} else {
await this.openView({ activate: true, reveal: true });
}
}
protected renderAutoScrollButton(): React.ReactNode { protected renderAutoScrollButton(): React.ReactNode {
return <React.Fragment key='autoscroll-toolbar-item'> return <React.Fragment key='autoscroll-toolbar-item'>
<div <div