Merge pull request #2540 from Tyriar/ts37

Update TS to 3.7 and adopt optional chaining
This commit is contained in:
Daniel Imms
2019-11-05 11:22:11 -08:00
committed by GitHub
7 changed files with 38 additions and 82 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
"ts-loader": "^6.0.4",
"tslint": "^5.18.0",
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "3.6",
"typescript": "3.7",
"utf8": "^3.0.0",
"webpack": "^4.35.3",
"webpack-cli": "^3.1.0",
+22 -60
View File
@@ -240,18 +240,12 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
return;
}
super.dispose();
if (this._windowsMode) {
this._windowsMode.dispose();
this._windowsMode = undefined;
}
if (this._renderService) {
this._renderService.dispose();
}
this._windowsMode?.dispose();
this._windowsMode = undefined;
this._renderService?.dispose();
this._customKeyEventHandler = null;
this.write = () => {};
if (this.element && this.element.parentNode) {
this.element.parentNode.removeChild(this.element);
}
this.element?.parentNode?.removeChild(this.element);
}
private _setup(): void {
@@ -336,12 +330,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
case 'fontFamily':
case 'fontSize':
// When the font changes the size of the cells may change which requires a renderer clear
if (this._renderService) {
this._renderService.clear();
}
if (this._charSizeService) {
this._charSizeService.measure();
}
this._renderService?.clear();
this._charSizeService?.measure();
break;
case 'drawBoldTextInBrightColors':
case 'letterSpacing':
@@ -363,9 +353,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
break;
case 'scrollback':
this.buffers.resize(this.cols, this.rows);
if (this.viewport) {
this.viewport.syncScrollArea();
}
this.viewport?.syncScrollArea();
break;
case 'screenReaderMode':
if (this.optionsService.options.screenReaderMode) {
@@ -373,10 +361,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._accessibilityManager = new AccessibilityManager(this, this._renderService);
}
} else {
if (this._accessibilityManager) {
this._accessibilityManager.dispose();
this._accessibilityManager = null;
}
this._accessibilityManager?.dispose();
this._accessibilityManager = null;
}
break;
case 'tabStopWidth': this.buffers.setupTabStops(); break;
@@ -389,10 +375,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._windowsMode = applyWindowsMode(this);
}
} else {
if (this._windowsMode) {
this._windowsMode.dispose();
this._windowsMode = undefined;
}
this._windowsMode?.dispose();
this._windowsMode = undefined;
}
break;
}
@@ -665,15 +649,9 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
*/
private _setTheme(theme: ITheme): void {
this._theme = theme;
if (this._colorManager) {
this._colorManager.setTheme(theme);
}
if (this._renderService) {
this._renderService.setColors(this._colorManager.colors);
}
if (this.viewport) {
this.viewport.onThemeChange(this._colorManager.colors);
}
this._colorManager?.setTheme(theme);
this._renderService?.setColors(this._colorManager.colors);
this.viewport?.onThemeChange(this._colorManager.colors);
}
/**
@@ -940,9 +918,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* @param end The row to end at (between start and this.rows - 1).
*/
public refresh(start: number, end: number): void {
if (this._renderService) {
this._renderService.refreshRows(start, end);
}
this._renderService?.refreshRows(start, end);
}
/**
@@ -951,9 +927,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* @param end The row to end at (between start and this.rows - 1).
*/
private _queueLinkification(start: number, end: number): void {
if (this.linkifier) {
this.linkifier.linkifyRows(start, end);
}
this.linkifier?.linkifyRows(start, end);
}
/**
@@ -1233,24 +1207,18 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Clears the current terminal selection.
*/
public clearSelection(): void {
if (this._selectionService) {
this._selectionService.clearSelection();
}
this._selectionService?.clearSelection();
}
/**
* Selects all text within the terminal.
*/
public selectAll(): void {
if (this._selectionService) {
this._selectionService.selectAll();
}
this._selectionService?.selectAll();
}
public selectLines(start: number, end: number): void {
if (this._selectionService) {
this._selectionService.selectLines(start, end);
}
this._selectionService?.selectLines(start, end);
}
/**
@@ -1457,9 +1425,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._bufferService.resize(x, y);
this.buffers.setupTabStops(this.cols);
if (this._charSizeService) {
this._charSizeService.measure();
}
this._charSizeService?.measure();
// Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an
// invalid location
@@ -1551,9 +1517,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._bufferService.reset();
this._coreService.reset();
this._coreMouseService.reset();
if (this._selectionService) {
this._selectionService.reset();
}
this._selectionService?.reset();
// reattach
this._customKeyEventHandler = customKeyEventHandler;
@@ -1563,9 +1527,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
// do a full screen refresh
this.refresh(0, this.rows - 1);
if (this.viewport) {
this.viewport.syncScrollArea();
}
this.viewport?.syncScrollArea();
}
// TODO: Remove cancel function and cancelEvents option
+6 -6
View File
@@ -82,12 +82,12 @@ export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextA
// Reset the terminal textarea's styling
// Timeout needs to be long enough for click event to be handled.
setTimeout(() => {
textarea.style.position = null;
textarea.style.width = null;
textarea.style.height = null;
textarea.style.left = null;
textarea.style.top = null;
textarea.style.zIndex = null;
textarea.style.position = '';
textarea.style.width = '';
textarea.style.height = '';
textarea.style.left = '';
textarea.style.top = '';
textarea.style.zIndex = '';
}, 200);
}
+3 -5
View File
@@ -175,11 +175,9 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager {
// Find the active zone, prevent event propagation if found to prevent other
// components from handling the mouse event.
const zone = this._findZoneEventAt(e);
if (zone) {
if (zone.willLinkActivate(e)) {
e.preventDefault();
e.stopImmediatePropagation();
}
if (zone?.willLinkActivate(e)) {
e.preventDefault();
e.stopImmediatePropagation();
}
}
+1 -3
View File
@@ -60,9 +60,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
public dispose(): void {
this._container.removeChild(this._canvas);
if (this._charAtlas) {
this._charAtlas.dispose();
}
this._charAtlas?.dispose();
}
private _initCanvas(): void {
+1 -3
View File
@@ -688,9 +688,7 @@ export class SelectionService implements ISelectionService {
// reverseIndex) and delete in a splice is only ever used when the same
// number of elements was just added. Given this is could actually be
// beneficial to leave the selection as is for these cases.
if (this._trimListener) {
this._trimListener.dispose();
}
this._trimListener.dispose();
this._trimListener = e.activeBuffer.lines.onTrim(amount => this._onTrim(amount));
}
+4 -4
View File
@@ -5184,10 +5184,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@3.6:
version "3.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da"
integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==
typescript@3.7:
version "3.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==
typescript@^3.5.1:
version "3.5.1"