Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected connectTerminalProcess(): void {
if (typeof this.terminalId !== 'number') {
return;
}
this.toDisposeOnConnect.dispose();
this.toDispose.push(this.toDisposeOnConnect);
this.term.reset();
const waitForConnection = this.waitForConnection = new Deferred();
this.webSocketConnectionProvider.listen({
path: `${terminalsPath}/${this.terminalId}`,
onConnection: connection => {
connection.onNotification('onData', (data: string) => this.write(data));
// Excludes the device status code emitted by Xterm.js
const sendData = (data?: string) => {
if (data && !this.deviceStatusCodes.has(data)) {
return connection.sendRequest('write', data);
}
};
const disposable = this.term.onData(sendData);
connection.onDispose(() => disposable.dispose());
this.toDisposeOnConnect.push(connection);
async updateStoragePath(roots: FileStat[]): Promise {
const workspace = this.workspaceService.workspace;
if (!workspace) {
this.path = undefined;
}
const newPath = await this.pluginPathsService.provideHostStoragePath(workspace, roots);
if (this.path !== newPath) {
this.path = newPath;
this.pathDeferred.resolve(this.path);
this.pathDeferred = new Deferred();
this.pathDeferred.resolve(this.path);
this.onStoragePathChangeEmitter.fire(this.path);
}
}
sync(): Promise {
if (this.idle) {
if (this.interruptIdle) {
this.interruptIdle();
}
} else {
this.skipNextIdle = true;
}
const result = new Deferred();
this.syncWorkPromises.push(result);
return result.promise;
}
protected createConnection(): void {
if (!IBaseTerminalServer.validateId(this.terminalId)) {
return;
}
this.toDisposeOnConnect.dispose();
this.toDispose.push(this.toDisposeOnConnect);
this.widget.reset();
const waitForConnection = this.waitForConnection = new Deferred();
this.webSocketConnectionProvider.listen({
path: `${terminalsPath}/${this.terminalId}`,
onConnection: connection => {
connection.onNotification('onData', (data: string) => this.widget.write(data));
this.toDisposeOnConnect.push(this.widget.onUserInput(data => data && connection.sendRequest('write', data)));
this.toDisposeOnConnect.push(connection);
connection.listen();
if (waitForConnection) {
waitForConnection.resolve(connection);
}
}
}, { reconnecting: false });
}
if (!notification) {
const message = this.renderMessage(plainMessage.text);
const type = this.toNotificationType(plainMessage.type);
const actions = Array.from(new Set(plainMessage.actions));
const source = plainMessage.source;
const expandable = this.isExpandable(message, source, actions);
const collapsed = expandable;
notification = { messageId, message, type, actions, expandable, collapsed };
this.notifications.set(messageId, notification);
notification.progress = 0;
cancellationToken.onCancellationRequested(() => {
this.accept(messageId, ProgressMessage.Cancel);
});
}
const result = this.deferredResults.get(messageId) || new Deferred();
this.deferredResults.set(messageId, result);
if (!this.centerVisible) {
this.toasts.set(messageId, notification);
this.setVisibilityState('toasts');
}
this.fireUpdatedEvent();
return result.promise;
}
async setMostRecentlyUsedWorkspace(uri: string): Promise {
this.root = new Deferred();
const listUri: string[] = [];
const oldListUri = await this.getRecentWorkspaces();
listUri.push(uri);
if (oldListUri) {
oldListUri.forEach(element => {
if (element !== uri && element.length > 0) {
listUri.push(element);
}
});
}
this.root.resolve(uri);
this.writeToUserHome({
recentRoots: listUri
});
}