From 9315b5089710d557f690ae982d9662d5105f55c8 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 13 Jul 2019 22:56:54 -0700 Subject: [PATCH] Use createInstance on service hungry objects --- src/Terminal.ts | 9 +++------ src/browser/MouseZoneManager.ts | 6 +++--- src/browser/Viewport.ts | 6 +++--- src/browser/input/CompositionHelper.ts | 8 ++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index 08783230c..aee393b3e 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -612,13 +612,10 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp this._mouseService = this._instantiationService.createInstance(MouseService); this._instantiationService.setService(IMouseService, this._mouseService); - this.viewport = new Viewport( + this.viewport = this._instantiationService.createInstance(Viewport, (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent), this._viewportElement, - this._viewportScrollArea, - this._bufferService, - this._charSizeService, - this._renderService + this._viewportScrollArea ); this.viewport.onThemeChange(this._colorManager.colors); this.register(this.viewport); @@ -651,7 +648,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp })); this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService.refresh())); - this._mouseZoneManager = new MouseZoneManager(this.element, this.screenElement, this._bufferService, this._mouseService, this._selectionService); + this._mouseZoneManager = this._instantiationService.createInstance(MouseZoneManager, this.element, this.screenElement); this.register(this._mouseZoneManager); this.register(this.onScroll(() => this._mouseZoneManager.clearAll())); this.linkifier.attachToDom(this.element, this._mouseZoneManager); diff --git a/src/browser/MouseZoneManager.ts b/src/browser/MouseZoneManager.ts index 589428f8d..7eb7c5f89 100644 --- a/src/browser/MouseZoneManager.ts +++ b/src/browser/MouseZoneManager.ts @@ -35,9 +35,9 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager { constructor( private readonly _element: HTMLElement, private readonly _screenElement: HTMLElement, - private readonly _bufferService: IBufferService, - private readonly _mouseService: IMouseService, - private readonly _selectionService: ISelectionService + @IBufferService private readonly _bufferService: IBufferService, + @IMouseService private readonly _mouseService: IMouseService, + @ISelectionService private readonly _selectionService: ISelectionService ) { super(); diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 270d4c672..9625588d5 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -36,9 +36,9 @@ export class Viewport extends Disposable implements IViewport { private readonly _scrollLines: (amount: number, suppressEvent: boolean) => void, private readonly _viewportElement: HTMLElement, private readonly _scrollArea: HTMLElement, - private readonly _bufferService: IBufferService, - private readonly _charSizeService: ICharSizeService, - private readonly _renderService: IRenderService + @IBufferService private readonly _bufferService: IBufferService, + @ICharSizeService private readonly _charSizeService: ICharSizeService, + @IRenderService private readonly _renderService: IRenderService ) { super(); diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index a8c8bb145..e6994ea3b 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -37,10 +37,10 @@ export class CompositionHelper { constructor( private readonly _textarea: HTMLTextAreaElement, private readonly _compositionView: HTMLElement, - private readonly _bufferService: IBufferService, - private readonly _optionsService: IOptionsService, - private readonly _charSizeService: ICharSizeService, - private readonly _coreService: ICoreService + @IBufferService private readonly _bufferService: IBufferService, + @IOptionsService private readonly _optionsService: IOptionsService, + @ICharSizeService private readonly _charSizeService: ICharSizeService, + @ICoreService private readonly _coreService: ICoreService ) { this._isComposing = false; this._isSendingComposition = false;