Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)

* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c

* remove files we don't want

* fix hygiene

* update distro

* update distro

* fix hygiene

* fix strict nulls

* distro

* distro

* fix tests

* fix tests

* add another edit

* fix viewlet icon

* fix azure dialog

* fix some padding

* fix more padding issues
This commit is contained in:
Anthony Dresser
2019-12-04 19:28:22 -08:00
committed by GitHub
parent a8818ab0df
commit f5ce7fb2a5
1507 changed files with 42813 additions and 27370 deletions

View File

@@ -31,7 +31,7 @@ import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/term
import { TerminalLinkHandler } from 'vs/workbench/contrib/terminal/browser/terminalLinkHandler';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { ITerminalInstanceService, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ITerminalInstanceService, ITerminalInstance, TerminalShellType } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/browser/terminalProcessManager';
import { Terminal as XTermTerminal, IBuffer, ITerminalAddon } from 'xterm';
import { SearchAddon, ISearchOptions } from 'xterm-addon-search';
@@ -54,11 +54,11 @@ export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [
TERMINAL_COMMAND_ID.DELETE_WORD_RIGHT,
TERMINAL_COMMAND_ID.FIND_WIDGET_FOCUS,
TERMINAL_COMMAND_ID.FIND_WIDGET_HIDE,
TERMINAL_COMMAND_ID.FIND_NEXT_TERMINAL_FOCUS,
TERMINAL_COMMAND_ID.FIND_PREVIOUS_TERMINAL_FOCUS,
TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX_TERMINAL_FOCUS,
TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD_TERMINAL_FOCUS,
TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE_TERMINAL_FOCUS,
TERMINAL_COMMAND_ID.FIND_NEXT,
TERMINAL_COMMAND_ID.FIND_PREVIOUS,
TERMINAL_COMMAND_ID.TOGGLE_FIND_REGEX,
TERMINAL_COMMAND_ID.TOGGLE_FIND_WHOLE_WORD,
TERMINAL_COMMAND_ID.TOGGLE_FIND_CASE_SENSITIVE,
TERMINAL_COMMAND_ID.FOCUS_NEXT_PANE,
TERMINAL_COMMAND_ID.FOCUS_NEXT,
TERMINAL_COMMAND_ID.FOCUS_PREVIOUS_PANE,
@@ -181,7 +181,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _hadFocusOnExit: boolean;
private _isVisible: boolean;
private _isDisposed: boolean;
private _exitCode: number | undefined;
private _skipTerminalCommands: string[];
private _shellType: TerminalShellType;
private _title: string = '';
private _wrapperElement: (HTMLElement & { xterm?: XTermTerminal }) | undefined;
private _xterm: XTermTerminal | undefined;
@@ -226,10 +228,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// TODO: How does this work with detached processes?
// TODO: Should this be an event as it can fire twice?
public get processReady(): Promise<void> { return this._processManager.ptyProcessReady; }
public get exitCode(): number | undefined { return this._exitCode; }
public get title(): string { return this._title; }
public get hadFocusOnExit(): boolean { return this._hadFocusOnExit; }
public get isTitleSetByProcess(): boolean { return !!this._messageTitleDisposable; }
public get shellLaunchConfig(): IShellLaunchConfig { return this._shellLaunchConfig; }
public get shellType(): TerminalShellType { return this._shellType; }
public get commandTracker(): CommandTrackerAddon | undefined { return this._commandTrackerAddon; }
public get navigationMode(): INavigationMode | undefined { return this._navigationModeAddon; }
@@ -305,7 +309,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
});
this.addDisposable(this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('terminal.integrated')) {
if (e.affectsConfiguration('terminal.integrated') || e.affectsConfiguration('editor.fastScrollSensitivity') || e.affectsConfiguration('editor.mouseWheelScrollSensitivity')) {
this.updateConfig();
// HACK: Trigger another async layout to ensure xterm's CharMeasure is ready to use,
// this hack can be removed when https://github.com/xtermjs/xterm.js/issues/702 is
@@ -365,12 +369,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// when window.devicePixelRatio changes.
const scaledWidthAvailable = dimension.width * window.devicePixelRatio;
let scaledCharWidth: number;
if (this._configHelper.config.rendererType === 'dom') {
scaledCharWidth = font.charWidth * window.devicePixelRatio;
} else {
scaledCharWidth = Math.floor(font.charWidth * window.devicePixelRatio) + font.letterSpacing;
}
const scaledCharWidth = font.charWidth * window.devicePixelRatio + font.letterSpacing;
const newCols = Math.max(Math.floor(scaledWidthAvailable / scaledCharWidth), 1);
const scaledHeightAvailable = dimension.height * window.devicePixelRatio;
@@ -421,7 +420,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const bottom = parseInt(wrapperElementStyle.bottom!.split('px')[0], 10);
const innerWidth = width - marginLeft - marginRight;
const innerHeight = height - bottom;
const innerHeight = height - bottom - 1;
TerminalInstance._lastKnownCanvasDimensions = new dom.Dimension(innerWidth, innerHeight);
return TerminalInstance._lastKnownCanvasDimensions;
@@ -448,7 +447,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const Terminal = await this._getXtermConstructor();
const font = this._configHelper.getFont(undefined, true);
const config = this._configHelper.config;
const fastScrollSensitivity = this._configurationService.getValue<IEditorOptions>('editor.fastScrollSensitivity').fastScrollSensitivity;
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
const xterm = new Terminal({
scrollback: config.scrollback,
theme: this._getXtermTheme(),
@@ -459,14 +459,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
fontSize: font.fontSize,
letterSpacing: font.letterSpacing,
lineHeight: font.lineHeight,
minimumContrastRatio: config.minimumContrastRatio,
bellStyle: config.enableBell ? 'sound' : 'none',
macOptionIsMeta: config.macOptionIsMeta,
macOptionClickForcesSelection: config.macOptionClickForcesSelection,
rightClickSelectsWord: config.rightClickBehavior === 'selectWord',
fastScrollModifier: 'alt',
fastScrollSensitivity,
// TODO: Guess whether to use canvas or dom better
rendererType: config.rendererType === 'auto' ? 'canvas' : config.rendererType
fastScrollSensitivity: editorOptions.fastScrollSensitivity,
scrollSensitivity: editorOptions.mouseWheelScrollSensitivity,
rendererType: config.rendererType === 'auto' || config.rendererType === 'experimentalWebgl' ? 'canvas' : config.rendererType,
wordSeparator: ' ()[]{}\',:;"`'
});
this._xterm = xterm;
this._xtermCore = (xterm as any)._core as XTermCore;
@@ -484,7 +486,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._processManager.onProcessData(data => this._onProcessData(data));
this._xterm.onData(data => this._processManager.write(data));
// TODO: How does the cwd work on detached processes?
this.processReady.then(async () => {
if (this._linkHandler) {
this._linkHandler.processCwd = await this._processManager.getInitialCwd();
@@ -524,9 +525,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
throw new Error('The terminal instance has not been attached to a container yet');
}
if (this._wrapperElement.parentNode) {
this._wrapperElement.parentNode.removeChild(this._wrapperElement);
}
this._wrapperElement.parentNode?.removeChild(this._wrapperElement);
this._container = container;
this._container.appendChild(this._wrapperElement);
}
@@ -544,9 +543,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
// The container changed, reattach
if (this._container) {
this._container.removeChild(this._wrapperElement);
}
this._container?.removeChild(this._wrapperElement);
this._container = container;
this._container.appendChild(this._wrapperElement);
}
@@ -568,6 +565,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._wrapperElement.appendChild(this._xtermElement);
this._container.appendChild(this._wrapperElement);
xterm.open(this._xtermElement);
if (this._configHelper.config.rendererType === 'experimentalWebgl') {
this._terminalInstanceService.getXtermWebglConstructor().then(Addon => {
xterm.loadAddon(new Addon());
});
}
if (!xterm.element || !xterm.textarea) {
throw new Error('xterm elements not set after open');
@@ -584,7 +586,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// within commandsToSkipShell
const standardKeyboardEvent = new StandardKeyboardEvent(event);
const resolveResult = this._keybindingService.softDispatch(standardKeyboardEvent, standardKeyboardEvent.target);
const allowChords = resolveResult && resolveResult.enterChord && this._configHelper.config.allowChords;
// Respect chords if the allowChords setting is set and it's not Escape. Escape is
// handled specially for Zen Mode's Escape, Escape chord, plus it's important in
// terminals generally
const allowChords = resolveResult && resolveResult.enterChord && this._configHelper.config.allowChords && event.key !== 'Escape';
if (allowChords || resolveResult && this._skipTerminalCommands.some(k => k === resolveResult.commandId)) {
event.preventDefault();
return false;
@@ -594,6 +599,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (TabFocus.getTabFocusMode() && event.keyCode === 9) {
return false;
}
// Always have alt+F4 skip the terminal on Windows and allow it to be handled by the
// system
if (platform.isWindows && event.altKey && event.key === 'F4' && !event.ctrlKey) {
@@ -652,11 +658,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const widgetManager = new TerminalWidgetManager(this._wrapperElement);
this._widgetManager = widgetManager;
this._processManager.onProcessReady(() => {
if (this._linkHandler) {
this._linkHandler.setWidgetManager(widgetManager);
}
});
this._processManager.onProcessReady(() => this._linkHandler?.setWidgetManager(widgetManager));
const computedStyle = window.getComputedStyle(this._container);
const width = parseInt(computedStyle.getPropertyValue('width').replace('px', ''), 10);
@@ -751,19 +753,13 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
public clearSelection(): void {
if (!this._xterm) {
return;
}
this._xterm.clearSelection();
this._xterm?.clearSelection();
}
public selectAll(): void {
if (!this._xterm) {
return;
}
// Focus here to ensure the terminal context key is set
this._xterm.focus();
this._xterm.selectAll();
this._xterm?.focus();
this._xterm?.selectAll();
}
public findNext(term: string, searchOptions: ISearchOptions): boolean {
@@ -924,45 +920,31 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
public scrollDownLine(): void {
if (this._xterm) {
this._xterm.scrollLines(1);
}
this._xterm?.scrollLines(1);
}
public scrollDownPage(): void {
if (this._xterm) {
this._xterm.scrollPages(1);
}
this._xterm?.scrollPages(1);
}
public scrollToBottom(): void {
if (this._xterm) {
this._xterm.scrollToBottom();
}
this._xterm?.scrollToBottom();
}
public scrollUpLine(): void {
if (this._xterm) {
this._xterm.scrollLines(-1);
}
this._xterm?.scrollLines(-1);
}
public scrollUpPage(): void {
if (this._xterm) {
this._xterm.scrollPages(-1);
}
this._xterm?.scrollPages(-1);
}
public scrollToTop(): void {
if (this._xterm) {
this._xterm.scrollToTop();
}
this._xterm?.scrollToTop();
}
public clear(): void {
if (this._xterm) {
this._xterm.clear();
}
this._xterm?.clear();
}
private _refreshSelectionContextKey() {
@@ -1019,12 +1001,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
private _onProcessData(data: string): void {
if (this._widgetManager) {
this._widgetManager.closeMessage();
}
if (this._xterm) {
this._xterm.write(data);
}
this._widgetManager?.closeMessage();
this._xterm?.write(data);
}
/**
@@ -1041,6 +1019,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._logService.debug(`Terminal process exit (id: ${this.id}) with code ${exitCode}`);
this._exitCode = exitCode;
this._isExiting = true;
let exitCodeMessage: string | undefined;
@@ -1130,10 +1109,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
public reuseTerminal(shell: IShellLaunchConfig): void {
// Unsubscribe any key listener we may have.
if (this._pressAnyKeyToCloseListener) {
this._pressAnyKeyToCloseListener.dispose();
this._pressAnyKeyToCloseListener = undefined;
}
this._pressAnyKeyToCloseListener?.dispose();
this._pressAnyKeyToCloseListener = undefined;
// Kill and clear up the process, making the process manager ready for a new process
this._processManager.dispose();
@@ -1243,11 +1220,18 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._setCommandsToSkipShell(config.commandsToSkipShell);
this._setEnableBell(config.enableBell);
this._safeSetOption('scrollback', config.scrollback);
this._safeSetOption('minimumContrastRatio', config.minimumContrastRatio);
this._safeSetOption('macOptionIsMeta', config.macOptionIsMeta);
this._safeSetOption('macOptionClickForcesSelection', config.macOptionClickForcesSelection);
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
this._safeSetOption('fastScrollSensitivity', this._configurationService.getValue<IEditorOptions>('editor.fastScrollSensitivity').fastScrollSensitivity);
if (config.rendererType !== 'experimentalWebgl') {
// Never set webgl as it's an addon not a rendererType
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
}
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
this._safeSetOption('fastScrollSensitivity', editorOptions.fastScrollSensitivity);
this._safeSetOption('scrollSensitivity', editorOptions.mouseWheelScrollSensitivity);
}
public updateAccessibilitySupport(): void {
@@ -1256,10 +1240,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._navigationModeAddon = new NavigationModeAddon(this._terminalA11yTreeFocusContextKey);
this._xterm!.loadAddon(this._navigationModeAddon);
} else {
if (this._navigationModeAddon) {
this._navigationModeAddon.dispose();
this._navigationModeAddon = undefined;
}
this._navigationModeAddon?.dispose();
this._navigationModeAddon = undefined;
}
this._xterm!.setOption('screenReaderMode', isEnabled);
}
@@ -1375,6 +1357,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._processManager.ptyProcessReady.then(() => this._processManager.setDimensions(cols, rows));
}
public setShellType(shellType: TerminalShellType) {
this._shellType = shellType;
}
public setTitle(title: string | undefined, eventSource: TitleEventSource): void {
if (!title) {
return;