Skip to content

Commit

Permalink
Rename Terminal.sendText addNewLine parameter to align with vscode api
Browse files Browse the repository at this point in the history
fixes #13235

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
  • Loading branch information
rschnekenbu committed Jan 3, 2024
1 parent 72421be commit ed37e55
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## not yet released

- [terminal] rename terminal.sendText() parameter from addNewLine to shouldExecute [#13236](https://github.com/eclipse-theia/theia/pull/13236) - contributed on behalf of STMicroelectronics

## v1.45.0 - 12/21/2023

- [application-manager] updated logic to allow rebinding messaging services in preload [#13199](https://github.com/eclipse-theia/theia/pull/13199)
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/main/browser/terminal-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/terminal-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ed37e55

Please sign in to comment.