mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
VSCode merge (#4610)
* Merge from vscode e388c734f30757875976c7e326d6cfeee77710de * fix yarn lcoks * remove small issue
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
@@ -262,7 +262,7 @@ configurationRegistry.registerConfiguration({
|
||||
'terminal.integrated.windowsEnableConpty': {
|
||||
description: nls.localize('terminal.integrated.windowsEnableConpty', "Whether to use ConPTY for Windows terminal process communication (requires Windows 10 build number 18309+). Winpty will be used if this is false."),
|
||||
type: 'boolean',
|
||||
default: false
|
||||
default: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,6 +27,11 @@ import { IRemoteEnvironmentService } from 'vs/workbench/services/remote/common/r
|
||||
/** The amount of time to consider terminal errors to be related to the launch */
|
||||
const LAUNCHING_DURATION = 500;
|
||||
|
||||
/**
|
||||
* The minimum amount of time between latency requests.
|
||||
*/
|
||||
const LATENCY_MEASURING_INTERVAL = 1000;
|
||||
|
||||
/**
|
||||
* Holds all state related to the creation and management of terminal processes.
|
||||
*
|
||||
@@ -46,6 +51,9 @@ export class TerminalProcessManager implements ITerminalProcessManager {
|
||||
private _process: ITerminalChildProcess | null = null;
|
||||
private _preLaunchInputQueue: string[] = [];
|
||||
private _disposables: IDisposable[] = [];
|
||||
private _latency: number = -1;
|
||||
private _latencyRequest: Promise<number>;
|
||||
private _latencyLastMeasured: number = 0;
|
||||
|
||||
private readonly _onProcessReady = new Emitter<void>();
|
||||
public get onProcessReady(): Event<void> { return this._onProcessReady.event; }
|
||||
@@ -77,6 +85,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
|
||||
c(undefined);
|
||||
});
|
||||
});
|
||||
this.ptyProcessReady.then(async () => await this.getLatency());
|
||||
}
|
||||
|
||||
public dispose(immediate: boolean = false): void {
|
||||
@@ -240,6 +249,18 @@ export class TerminalProcessManager implements ITerminalProcessManager {
|
||||
return this._process.getCwd();
|
||||
}
|
||||
|
||||
public async getLatency(): Promise<number> {
|
||||
if (!this._process) {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
if (this._latencyLastMeasured === 0 || this._latencyLastMeasured + LATENCY_MEASURING_INTERVAL < Date.now()) {
|
||||
this._latencyRequest = this._process.getLatency();
|
||||
this._latency = await this._latencyRequest;
|
||||
this._latencyLastMeasured = Date.now();
|
||||
}
|
||||
return Promise.resolve(this._latency);
|
||||
}
|
||||
|
||||
private _onExit(exitCode: number): void {
|
||||
this._process = null;
|
||||
|
||||
|
||||
@@ -654,6 +654,7 @@ export interface ITerminalProcessManager extends IDisposable {
|
||||
|
||||
getInitialCwd(): Promise<string>;
|
||||
getCwd(): Promise<string>;
|
||||
getLatency(): Promise<number>;
|
||||
}
|
||||
|
||||
export const enum ProcessState {
|
||||
@@ -685,12 +686,14 @@ export interface ITerminalProcessExtHostProxy extends IDisposable {
|
||||
emitExit(exitCode: number): void;
|
||||
emitInitialCwd(initialCwd: string): void;
|
||||
emitCwd(cwd: string): void;
|
||||
emitLatency(latency: number): void;
|
||||
|
||||
onInput: Event<string>;
|
||||
onResize: Event<{ cols: number, rows: number }>;
|
||||
onShutdown: Event<boolean>;
|
||||
onRequestInitialCwd: Event<void>;
|
||||
onRequestCwd: Event<void>;
|
||||
onRequestLatency: Event<void>;
|
||||
}
|
||||
|
||||
export interface ITerminalProcessExtHostRequest {
|
||||
@@ -733,4 +736,5 @@ export interface ITerminalChildProcess {
|
||||
|
||||
getInitialCwd(): Promise<string>;
|
||||
getCwd(): Promise<string>;
|
||||
}
|
||||
getLatency(): Promise<number>;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,12 @@ export class TerminalProcessExtHostProxy implements ITerminalChildProcess, ITerm
|
||||
public get onRequestInitialCwd(): Event<void> { return this._onRequestInitialCwd.event; }
|
||||
private readonly _onRequestCwd = new Emitter<void>();
|
||||
public get onRequestCwd(): Event<void> { return this._onRequestCwd.event; }
|
||||
private readonly _onRequestLatency = new Emitter<void>();
|
||||
public get onRequestLatency(): Event<void> { return this._onRequestLatency.event; }
|
||||
|
||||
private _pendingInitialCwdRequests: ((value?: string | Thenable<string>) => void)[] = [];
|
||||
private _pendingCwdRequests: ((value?: string | Thenable<string>) => void)[] = [];
|
||||
private _pendingLatencyRequests: ((value?: number | Thenable<number>) => void)[] = [];
|
||||
|
||||
constructor(
|
||||
public terminalId: number,
|
||||
@@ -86,6 +89,12 @@ export class TerminalProcessExtHostProxy implements ITerminalChildProcess, ITerm
|
||||
}
|
||||
}
|
||||
|
||||
public emitLatency(latency: number): void {
|
||||
while (this._pendingLatencyRequests.length > 0) {
|
||||
this._pendingLatencyRequests.pop()!(latency);
|
||||
}
|
||||
}
|
||||
|
||||
public shutdown(immediate: boolean): void {
|
||||
this._onShutdown.fire(immediate);
|
||||
}
|
||||
@@ -111,4 +120,11 @@ export class TerminalProcessExtHostProxy implements ITerminalChildProcess, ITerm
|
||||
this._pendingCwdRequests.push(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
public getLatency(): Promise<number> {
|
||||
return new Promise<number>(resolve => {
|
||||
this._onRequestLatency.fire();
|
||||
this._pendingLatencyRequests.push(resolve);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export abstract class TerminalService implements ITerminalService {
|
||||
@INotificationService protected readonly _notificationService: INotificationService,
|
||||
@IDialogService private readonly _dialogService: IDialogService,
|
||||
@IExtensionService private readonly _extensionService: IExtensionService,
|
||||
@IFileService private readonly _fileService: IFileService
|
||||
@IFileService protected readonly _fileService: IFileService
|
||||
) {
|
||||
this._activeTabIndex = 0;
|
||||
this._isShuttingDown = false;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -27,6 +26,7 @@ import { coalesce } from 'vs/base/common/arrays';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { escapeNonWindowsPath } from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
|
||||
import { execFile } from 'child_process';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export class TerminalService extends BrowserTerminalService implements ITerminalService {
|
||||
public get configHelper(): ITerminalConfigHelper { return this._configHelper; }
|
||||
@@ -54,7 +54,8 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
|
||||
// the termProgram variable) and we are instructed to wait for editors close, wait for the
|
||||
// marker file to get deleted and then focus back to the integrated terminal.
|
||||
if (request.termProgram === 'vscode' && request.filesToWait) {
|
||||
pfs.whenDeleted(request.filesToWait.waitMarkerFilePath).then(() => {
|
||||
const waitMarkerFileUri = URI.revive(request.filesToWait.waitMarkerFileUri);
|
||||
this.whenDeleted(waitMarkerFileUri).then(() => {
|
||||
if (this.terminalInstances.length > 0) {
|
||||
const terminal = this.getActiveInstance();
|
||||
if (terminal) {
|
||||
@@ -73,6 +74,27 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
|
||||
});
|
||||
}
|
||||
|
||||
private whenDeleted(path: URI): Promise<void> {
|
||||
|
||||
// Complete when wait marker file is deleted
|
||||
return new Promise<void>(resolve => {
|
||||
let running = false;
|
||||
const interval = setInterval(() => {
|
||||
if (!running) {
|
||||
running = true;
|
||||
this._fileService.existsFile(path).then(exists => {
|
||||
running = false;
|
||||
|
||||
if (!exists) {
|
||||
clearInterval(interval);
|
||||
resolve(undefined);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
protected _getDefaultShell(p: platform.Platform): string {
|
||||
return getDefaultShell(p);
|
||||
}
|
||||
|
||||
@@ -213,4 +213,8 @@ export class TerminalProcess implements ITerminalChildProcess, IDisposable {
|
||||
resolve(this._initialCwd);
|
||||
});
|
||||
}
|
||||
|
||||
public getLatency(): Promise<number> {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user