From 59f037d79dd6ee1f3a378472b3fb99a03fae1672 Mon Sep 17 00:00:00 2001 From: Remi Schnekenburger Date: Wed, 3 Jan 2024 17:43:15 +0100 Subject: [PATCH] Rename Terminal.sendText addNewLine parameter to align with vscode api fixes #13235 contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger --- packages/plugin-ext/src/common/plugin-api-rpc.ts | 4 ++-- packages/plugin-ext/src/main/browser/terminal-main.ts | 4 ++-- packages/plugin-ext/src/plugin/terminal-ext.ts | 4 ++-- packages/plugin/src/theia.d.ts | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 5516220d17cd3..c0616d5177df6 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -327,9 +327,9 @@ export interface TerminalServiceMain { * Send text to the terminal by id. * @param id - terminal widget id. * @param text - text content. - * @param addNewLine - in case true - add new line after the text, otherwise - don't apply new line. + * @param shouldExecute - in case true - Indicates that the text being sent should be executed rather than just inserted in the terminal. */ - $sendText(id: string, text: string, addNewLine?: boolean): void; + $sendText(id: string, text: string, shouldExecute?: boolean): void; /** * Write data to the terminal by id. diff --git a/packages/plugin-ext/src/main/browser/terminal-main.ts b/packages/plugin-ext/src/main/browser/terminal-main.ts index fe1876c7bf8b4..590955fc27faa 100644 --- a/packages/plugin-ext/src/main/browser/terminal-main.ts +++ b/packages/plugin-ext/src/main/browser/terminal-main.ts @@ -181,11 +181,11 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, TerminalLin return undefined; } - $sendText(id: string, text: string, addNewLine?: boolean): void { + $sendText(id: string, text: string, shouldExecute?: boolean): void { const terminal = this.terminals.getById(id); if (terminal) { text = text.replace(/\r?\n/g, '\r'); - if (addNewLine && text.charAt(text.length - 1) !== '\r') { + if (shouldExecute && text.charAt(text.length - 1) !== '\r') { text += '\r'; } terminal.sendText(text); diff --git a/packages/plugin-ext/src/plugin/terminal-ext.ts b/packages/plugin-ext/src/plugin/terminal-ext.ts index 7c158fd36a8cb..627c322b4ec4b 100644 --- a/packages/plugin-ext/src/plugin/terminal-ext.ts +++ b/packages/plugin-ext/src/plugin/terminal-ext.ts @@ -463,8 +463,8 @@ export class TerminalExtImpl implements Terminal { this.creationOptions = this.options; } - sendText(text: string, addNewLine: boolean = true): void { - this.id.promise.then(id => this.proxy.$sendText(id, text, addNewLine)); + sendText(text: string, shouldExecute: boolean = true): void { + this.id.promise.then(id => this.proxy.$sendText(id, text, shouldExecute)); } show(preserveFocus?: boolean): void { diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 7451907b61cb5..8540b8ac45a1d 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -3042,10 +3042,11 @@ export module '@theia/plugin' { /** * Send text to the terminal. - * @param text - text content. - * @param addNewLine - in case true - apply new line after the text, otherwise don't apply new line. This defaults to `true`. + * @param text - The text to send. + * @param shouldExecute - Indicates that the text being sent should be executed rather than just inserted in the terminal. + * The character added is \r, independent from the platform (compared to platform specific in vscode). This defaults to `true`. */ - sendText(text: string, addNewLine?: boolean): void; + sendText(text: string, shouldExecute?: boolean): void; /** * Show created terminal on the UI.