mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Remove Terminal.onDidWriteData
Replaced by vscode.window.onDidWriteTerminalData Fixes #78574
This commit is contained in:
parent
ebe12f5889
commit
678abfe8b2
|
@ -78,11 +78,11 @@ class ServerReadyDetector extends vscode.Disposable {
|
|||
}
|
||||
this.shellPid = undefined;
|
||||
|
||||
terminals.forEach(terminal => {
|
||||
this.disposables.push(terminal.onDidWriteData(s => {
|
||||
this.detectPattern(s);
|
||||
}));
|
||||
});
|
||||
this.disposables.push(vscode.window.onDidWriteTerminalData(e => {
|
||||
if (terminals.indexOf(e.terminal) !== -1) {
|
||||
this.detectPattern(e.data);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
detectPattern(s: string): void {
|
||||
|
|
|
@ -152,22 +152,6 @@ suite('window namespace tests', () => {
|
|||
// });
|
||||
|
||||
suite('hideFromUser', () => {
|
||||
// test('should fire onDidWriteData correctly', done => {
|
||||
// const terminal = window.createTerminal({ name: 'bg', hideFromUser: true });
|
||||
// let data = '';
|
||||
// terminal.onDidWriteData(e => {
|
||||
// data += e;
|
||||
// if (data.indexOf('foo') !== -1) {
|
||||
// const reg3 = window.onDidCloseTerminal(() => {
|
||||
// reg3.dispose();
|
||||
// done();
|
||||
// });
|
||||
// terminal.dispose();
|
||||
// }
|
||||
// });
|
||||
// terminal.sendText('foo');
|
||||
// });
|
||||
|
||||
test('should be available to terminals API', done => {
|
||||
const terminal = window.createTerminal({ name: 'bg', hideFromUser: true });
|
||||
window.onDidOpenTerminal(t => {
|
||||
|
@ -247,33 +231,6 @@ suite('window namespace tests', () => {
|
|||
window.createTerminal({ name: 'c', pty });
|
||||
});
|
||||
|
||||
test('should fire Terminal.onData on write', (done) => {
|
||||
const reg1 = window.onDidOpenTerminal(async term => {
|
||||
equal(terminal, term);
|
||||
reg1.dispose();
|
||||
const reg2 = terminal.onDidWriteData(data => {
|
||||
equal(data, 'bar');
|
||||
reg2.dispose();
|
||||
const reg3 = window.onDidCloseTerminal(() => {
|
||||
reg3.dispose();
|
||||
done();
|
||||
});
|
||||
terminal.dispose();
|
||||
});
|
||||
await startPromise;
|
||||
writeEmitter.fire('bar');
|
||||
});
|
||||
let startResolve: () => void;
|
||||
const startPromise: Promise<void> = new Promise<void>(r => startResolve = r);
|
||||
const writeEmitter = new EventEmitter<string>();
|
||||
const pty: Pseudoterminal = {
|
||||
onDidWrite: writeEmitter.event,
|
||||
open: () => startResolve(),
|
||||
close: () => {}
|
||||
};
|
||||
const terminal = window.createTerminal({ name: 'foo', pty });
|
||||
});
|
||||
|
||||
// The below tests depend on global UI state and each other
|
||||
// test('should not provide dimensions on start as the terminal has not been shown yet', (done) => {
|
||||
// const reg1 = window.onDidOpenTerminal(term => {
|
||||
|
|
|
@ -21,7 +21,7 @@ suite('workspace-namespace', () => {
|
|||
const taskName = 'First custom task';
|
||||
const reg1 = vscode.window.onDidOpenTerminal(term => {
|
||||
reg1.dispose();
|
||||
const reg2 = term.onDidWriteData(e => {
|
||||
const reg2 = vscode.window.onDidWriteTerminalData(e => {
|
||||
reg2.dispose();
|
||||
assert.equal(e, 'testing\r\n');
|
||||
term.dispose();
|
||||
|
|
9
src/vs/vscode.proposed.d.ts
vendored
9
src/vs/vscode.proposed.d.ts
vendored
|
@ -778,15 +778,6 @@ declare module 'vscode' {
|
|||
* created.
|
||||
*/
|
||||
readonly dimensions: TerminalDimensions | undefined;
|
||||
|
||||
/**
|
||||
* Fires when the terminal's pty slave pseudo-device is written to. In other words, this
|
||||
* provides access to the raw data stream from the process running within the terminal,
|
||||
* including VT sequences.
|
||||
*
|
||||
* @deprecated Use [window.onDidWriteTerminalData](#onDidWriteTerminalData).
|
||||
*/
|
||||
readonly onDidWriteData: Event<string>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITerminalService, ITerminalInstance, IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ExtHostContext, ExtHostTerminalServiceShape, MainThreadTerminalServiceShape, MainContext, IExtHostContext, IShellLaunchConfigDto, TerminalLaunchConfig, ITerminalDimensionsDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
|
@ -21,7 +21,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
|||
private readonly _toDispose = new DisposableStore();
|
||||
private readonly _terminalProcesses = new Map<number, Promise<ITerminalProcessExtHostProxy>>();
|
||||
private readonly _terminalProcessesReady = new Map<number, (proxy: ITerminalProcessExtHostProxy) => void>();
|
||||
private readonly _terminalOnDidWriteDataListeners = new Map<number, IDisposable>();
|
||||
private _dataEventTracker: TerminalDataEventTracker | undefined;
|
||||
|
||||
constructor(
|
||||
|
@ -131,30 +130,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public $registerOnDataListener(terminalId: number): void {
|
||||
const terminalInstance = this._terminalService.getInstanceFromId(terminalId);
|
||||
if (!terminalInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Listener already registered
|
||||
if (this._terminalOnDidWriteDataListeners.has(terminalId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register
|
||||
const listener = terminalInstance.onData(data => {
|
||||
this._onTerminalData(terminalId, data);
|
||||
});
|
||||
this._terminalOnDidWriteDataListeners.set(terminalId, listener);
|
||||
terminalInstance.addDisposable(listener);
|
||||
}
|
||||
|
||||
public $startSendingDataEvents(): void {
|
||||
if (!this._dataEventTracker) {
|
||||
this._dataEventTracker = this._instantiationService.createInstance(TerminalDataEventTracker, (id, data) => {
|
||||
this._onTerminalData2(id, data);
|
||||
this._onTerminalData(id, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -170,15 +149,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
|||
this._proxy.$acceptActiveTerminalChanged(terminalId);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
private _onTerminalData(terminalId: number, data: string): void {
|
||||
this._proxy.$acceptTerminalProcessData(terminalId, data);
|
||||
}
|
||||
|
||||
private _onTerminalData2(terminalId: number, data: string): void {
|
||||
this._proxy.$acceptTerminalProcessData2(terminalId, data);
|
||||
}
|
||||
|
||||
private _onTitleChanged(terminalId: number, name: string): void {
|
||||
this._proxy.$acceptTerminalTitleChange(terminalId, name);
|
||||
}
|
||||
|
|
|
@ -398,8 +398,6 @@ export interface MainThreadTerminalServiceShape extends IDisposable {
|
|||
$hide(terminalId: number): void;
|
||||
$sendText(terminalId: number, text: string, addNewLine: boolean): void;
|
||||
$show(terminalId: number, preserveFocus: boolean): void;
|
||||
/** @deprecated */
|
||||
$registerOnDataListener(terminalId: number): void;
|
||||
$startSendingDataEvents(): void;
|
||||
$stopSendingDataEvents(): void;
|
||||
|
||||
|
@ -1154,9 +1152,7 @@ export interface ExtHostTerminalServiceShape {
|
|||
$acceptTerminalOpened(id: number, name: string): void;
|
||||
$acceptActiveTerminalChanged(id: number | null): void;
|
||||
$acceptTerminalProcessId(id: number, processId: number): void;
|
||||
/** @deprecated */
|
||||
$acceptTerminalProcessData(id: number, data: string): void;
|
||||
$acceptTerminalProcessData2(id: number, data: string): void;
|
||||
$acceptTerminalTitleChange(id: number, name: string): void;
|
||||
$acceptTerminalDimensions(id: number, cols: number, rows: number): void;
|
||||
$acceptTerminalMaximumDimensions(id: number, cols: number, rows: number): void;
|
||||
|
|
|
@ -97,17 +97,6 @@ export class ExtHostTerminal extends BaseExtHostTerminal implements vscode.Termi
|
|||
private _pidPromiseComplete: ((value: number | undefined) => any) | undefined;
|
||||
private _rows: number | undefined;
|
||||
|
||||
/** @deprecated */
|
||||
private readonly _onData = new Emitter<string>();
|
||||
/** @deprecated */
|
||||
public get onDidWriteData(): Event<string> {
|
||||
// Tell the main side to start sending data if it's not already
|
||||
this._idPromise.then(id => {
|
||||
this._proxy.$registerOnDataListener(id);
|
||||
});
|
||||
return this._onData.event;
|
||||
}
|
||||
|
||||
public isOpen: boolean = false;
|
||||
|
||||
constructor(
|
||||
|
@ -201,10 +190,6 @@ export class ExtHostTerminal extends BaseExtHostTerminal implements vscode.Termi
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
public _fireOnData(data: string): void {
|
||||
this._onData.fire(data);
|
||||
}
|
||||
}
|
||||
|
||||
class ApiRequest {
|
||||
|
@ -354,15 +339,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public async $acceptTerminalProcessData(id: number, data: string): Promise<void> {
|
||||
const terminal = await this._getTerminalByIdEventually(id);
|
||||
if (terminal) {
|
||||
terminal._fireOnData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public async $acceptTerminalProcessData2(id: number, data: string): Promise<void> {
|
||||
const terminal = await this._getTerminalByIdEventually(id);
|
||||
if (terminal) {
|
||||
this._onDidWriteTerminalData.fire({ terminal, data });
|
||||
|
|
Loading…
Reference in a new issue