Skip to content

Commit

Permalink
[vscode] Support Terminal#creationOptions eclipse-theia#11138
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Faltermeier <[email protected]>

Contributed on behalf of STMicroelectronics
  • Loading branch information
jfaltermeier committed Jun 21, 2022
1 parent b337a32 commit fea75ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/plugin-ext/src/plugin/terminal-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
};
}
this.proxy.$createTerminal(id, options, !!pseudoTerminal);
return this.obtainTerminal(id, options.name || 'Terminal');
return this.obtainTerminal(id, options.name || 'Terminal', options);
}

attachPtyToTerminal(terminalId: number, pty: theia.Pseudoterminal): void {
this._pseudoTerminals.set(terminalId.toString(), new PseudoTerminal(terminalId, this.proxy, pty, true));
}

protected obtainTerminal(id: string, name: string): TerminalExtImpl {
protected obtainTerminal(id: string, name: string, options?: theia.TerminalOptions): TerminalExtImpl {
let terminal = this._terminals.get(id);
if (!terminal) {
terminal = new TerminalExtImpl(this.proxy);
terminal = new TerminalExtImpl(this.proxy, options !== undefined ? options : {});
this._terminals.set(id, terminal);
}
terminal.name = name;
Expand Down Expand Up @@ -279,7 +279,11 @@ export class TerminalExtImpl implements Terminal {
return this.deferredProcessId.promise;
}

constructor(private readonly proxy: TerminalServiceMain) { }
readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;

constructor(private readonly proxy: TerminalServiceMain, private readonly options: theia.TerminalOptions) {
this.creationOptions = this.options;
}

sendText(text: string, addNewLine: boolean = true): void {
this.id.promise.then(id => this.proxy.$sendText(id, text, addNewLine));
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,12 @@ export module '@theia/plugin' {
*/
readonly exitStatus: TerminalExitStatus | undefined;

/**
* The object used to initialize the terminal, this is useful for example to detecting the shell type of when the terminal was not launched by this extension or for
* detecting what folder the shell was launched in.
*/
readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>

/**
* Send text to the terminal.
* @param text - text content.
Expand Down

0 comments on commit fea75ba

Please sign in to comment.