Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829

This commit is contained in:
ADS Merger
2020-08-06 07:08:52 +00:00
parent 9c67832880
commit 540046ba00
362 changed files with 7588 additions and 6584 deletions

View File

@@ -72,6 +72,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _pressAnyKeyToCloseListener: IDisposable | undefined;
private _id: number;
private _latestXtermWriteData: number = 0;
private _latestXtermParseData: number = 0;
private _isExiting: boolean;
private _hadFocusOnExit: boolean;
private _isVisible: boolean;
@@ -562,20 +564,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
setTimeout(() => this._refreshSelectionContextKey(), 0);
}));
const xtermHelper: HTMLElement = <HTMLElement>xterm.element.querySelector('.xterm-helpers');
const focusTrap: HTMLElement = document.createElement('div');
focusTrap.setAttribute('tabindex', '0');
dom.addClass(focusTrap, 'focus-trap');
this._register(dom.addDisposableListener(focusTrap, 'focus', () => {
let currentElement = focusTrap;
while (!dom.hasClass(currentElement, 'part')) {
currentElement = currentElement.parentElement!;
}
const hidePanelElement = currentElement.querySelector<HTMLElement>('.hide-panel-action');
hidePanelElement?.focus();
}));
xtermHelper.insertBefore(focusTrap, xterm.textarea);
this._register(dom.addDisposableListener(xterm.textarea, 'focus', () => {
this._terminalFocusContextKey.set(true);
if (this.shellType) {
@@ -959,7 +947,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
private _onProcessData(data: string): void {
this._xterm?.write(data);
const messageId = ++this._latestXtermWriteData;
this._xterm?.write(data, () => this._latestXtermParseData = messageId);
}
/**
@@ -968,15 +957,17 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
* @param exitCode The exit code of the process, this is undefined when the terminal was exited
* through user action.
*/
private _onProcessExit(exitCodeOrError?: number | ITerminalLaunchError): void {
private async _onProcessExit(exitCodeOrError?: number | ITerminalLaunchError): Promise<void> {
// Prevent dispose functions being triggered multiple times
if (this._isExiting) {
return;
}
this._isExiting = true;
await this._flushXtermData();
this._logService.debug(`Terminal process exit (id: ${this.id}) with code ${this._exitCode}`);
this._isExiting = true;
let exitCodeMessage: string | undefined;
// Create exit code message
@@ -1061,6 +1052,24 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._onExit.fire(this._exitCode);
}
/**
* Ensure write calls to xterm.js have finished before resolving.
*/
private _flushXtermData(): Promise<void> {
if (this._latestXtermWriteData === this._latestXtermParseData) {
return Promise.resolve();
}
let retries = 0;
return new Promise<void>(r => {
const interval = setInterval(() => {
if (this._latestXtermWriteData === this._latestXtermParseData || ++retries === 5) {
clearInterval(interval);
r();
}
}, 20);
});
}
private _attachPressAnyKeyToCloseListener(xterm: XTermTerminal) {
if (xterm.textarea && !this._pressAnyKeyToCloseListener) {
this._pressAnyKeyToCloseListener = dom.addDisposableListener(xterm.textarea, 'keypress', (event: KeyboardEvent) => {

View File

@@ -218,7 +218,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: false
},
'terminal.integrated.commandsToSkipShell': {
markdownDescription: localize('terminal.integrated.commandsToSkipShell', "A set of command IDs whose keybindings will not be sent to the shell but instead always be handled by VS Code. This allows keybindings that would normally be consumed by the shell to act instead the same as when the terminal is not focused, for example `Ctrl+P` to launch Quick Open.\n\n---\n\nMany commands are skipped by default. To override a default and pass that command's keybinding to the shell instead, add the command prefixed with the `-` character. For example add `-workbench.action.quickOpen` to allow `Ctrl+P` to reach the shell.\n\n*The following list of default skipped commands is truncated when viewed in Settings Editor. To see the full list, [open the default settings JSON](command:workbench.action.openRawDefaultSettings 'Open Default Settings (JSON)') and search for the first command from the list below.*\n\n---\n\nDefault Skipped Commands:\n\n{0}", DEFAULT_COMMANDS_TO_SKIP_SHELL.sort().map(command => `- ${command}`).join('\n')),
markdownDescription: localize('terminal.integrated.commandsToSkipShell', "A set of command IDs whose keybindings will not be sent to the shell but instead always be handled by VS Code. This allows keybindings that would normally be consumed by the shell to act instead the same as when the terminal is not focused, for example `Ctrl+P` to launch Quick Open.\n\n&nbsp;\n\nMany commands are skipped by default. To override a default and pass that command's keybinding to the shell instead, add the command prefixed with the `-` character. For example add `-workbench.action.quickOpen` to allow `Ctrl+P` to reach the shell.\n\n&nbsp;\n\nThe following list of default skipped commands is truncated when viewed in Settings Editor. To see the full list, [open the default settings JSON](command:workbench.action.openRawDefaultSettings 'Open Default Settings (JSON)') and search for the first command from the list below.\n\n&nbsp;\n\nDefault Skipped Commands:\n\n{0}", DEFAULT_COMMANDS_TO_SKIP_SHELL.sort().map(command => `- ${command}`).join('\n')),
type: 'array',
items: {
type: 'string'