onDidClose property

Event<Object>? get onDidClose

An event that when fired will signal that the pty is closed and dispose of the terminal.

Events fired before {@link Pseudoterminal.open} is called will be be ignored.

A number can be used to provide an exit code for the terminal. Exit codes must be positive and a non-zero exit codes signals failure which shows a notification for a regular terminal and allows dependent tasks to proceed when used with the CustomExecution API.

Example: Exit the terminal when "y" is pressed, otherwise show a notification.

const writeEmitter = new vscode.EventEmitter<string>();
const closeEmitter = new vscode.EventEmitter<void>();
const pty: vscode.Pseudoterminal = {
  onDidWrite: writeEmitter.event,
  onDidClose: closeEmitter.event,
  open: () => writeEmitter.fire('Press y to exit successfully'),
  close: () => {},
  handleInput: data => {
    if (data !== 'y') {
      vscode.window.showInformationMessage('Something went wrong');
    }
    closeEmitter.fire();
  }
};
const terminal = vscode.window.createTerminal({ name: 'Exit example', pty });
terminal.show(true);

Implementation

_i3.Event<_i2.Object>? get onDidClose => _i5.getProperty(
      this,
      'onDidClose',
    );
set onDidClose (Event<Object>? value)

Implementation

set onDidClose(_i3.Event<_i2.Object>? value) {
  _i5.setProperty(
    this,
    'onDidClose',
    value ?? _i6.undefined,
  );
}