-
-
Save vince-fugnitto/1d0590adaa48eddcfdb02bb6877cfb03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { injectable, inject } from 'inversify'; | |
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser'; | |
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state'; | |
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service'; | |
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget'; | |
@injectable() | |
export class TerminalStartContribution implements FrontendApplicationContribution { | |
@inject(FrontendApplicationStateService) | |
protected readonly stateService: FrontendApplicationStateService; | |
@inject(TerminalService) | |
protected readonly terminalService: TerminalService; | |
protected readonly TERMINAL_ID = 'start:terminal:id' | |
async onStart(app: FrontendApplication): Promise<void> { | |
this.stateService.reachedState('ready').then( | |
async () => { | |
// Determine if a terminal currently exists, else skip. | |
if (this.terminalService.getById(this.TERMINAL_ID)) { | |
return; | |
} | |
// Create a new terminal, start it and activate it. | |
const terminal = await this.createTerminal(); | |
await terminal.start(); | |
this.terminalService.activateTerminal(terminal); | |
} | |
); | |
} | |
protected async createTerminal(): Promise<TerminalWidget> { | |
const terminal = await this.terminalService.newTerminal({ | |
id: this.TERMINAL_ID, | |
title: 'Vince', | |
destroyTermOnClose: true, | |
useServerTitle: false, | |
}); | |
return terminal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update:
On line 29:
activateTerminal()
no longer exists interminalService
.Instead, use
open()
: