Improve type safety around terminalTabbedView

Fixes #120926
This commit is contained in:
Daniel Imms 2021-04-09 05:27:13 -07:00
parent 611bda0dbd
commit b2b90e970c
No known key found for this signature in database
GPG key ID: D12BE8272D6284CC
3 changed files with 16 additions and 16 deletions

View file

@ -1038,28 +1038,26 @@ export class TerminalService implements ITerminalService {
public async focusFindWidget(): Promise<void> {
await this.showPanel(false);
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
pane.terminalTabbedView.focusFindWidget();
const pane = this._viewsService.getActiveViewWithId<TerminalViewPane>(TERMINAL_VIEW_ID);
pane?.terminalTabbedView?.focusFindWidget();
}
public hideFindWidget(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
pane.terminalTabbedView.hideFindWidget();
}
const pane = this._viewsService.getActiveViewWithId<TerminalViewPane>(TERMINAL_VIEW_ID);
pane?.terminalTabbedView?.hideFindWidget();
}
public findNext(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
const pane = this._viewsService.getActiveViewWithId<TerminalViewPane>(TERMINAL_VIEW_ID);
if (pane?.terminalTabbedView) {
pane.terminalTabbedView.showFindWidget();
pane.terminalTabbedView.getFindWidget().find(false);
}
}
public findPrevious(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
const pane = this._viewsService.getActiveViewWithId<TerminalViewPane>(TERMINAL_VIEW_ID);
if (pane?.terminalTabbedView) {
pane.terminalTabbedView.showFindWidget();
pane.terminalTabbedView.getFindWidget().find(true);
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { LayoutPriority, Orientation, Sizing, SplitView } from 'vs/base/browser/ui/splitview/splitview';
import { Orientation, Sizing, SplitView } from 'vs/base/browser/ui/splitview/splitview';
import { Disposable } from 'vs/base/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

View file

@ -35,8 +35,8 @@ export class TerminalViewPane extends ViewPane {
private _fontStyleElement: HTMLElement | undefined;
private _parentDomElement: HTMLElement | undefined;
private _tabsViewWrapper: HTMLElement | undefined;
private _terminalTabbedView!: TerminalTabbedView;
public get terminalTabbedView(): TerminalTabbedView { return this._terminalTabbedView; }
private _terminalTabbedView?: TerminalTabbedView;
public get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; }
private _terminalsInitialized = false;
private _bodyDimensions: { width: number, height: number } = { width: 0, height: 0 };
private _isWelcomeShowing: boolean = false;
@ -148,10 +148,12 @@ export class TerminalViewPane extends ViewPane {
protected override layoutBody(height: number, width: number): void {
super.layoutBody(height, width);
this._bodyDimensions.width = width;
this._bodyDimensions.height = height;
if (this._terminalTabbedView) {
this._bodyDimensions.width = width;
this._bodyDimensions.height = height;
this._terminalTabbedView.layout(width, height);
this._terminalTabbedView.layout(width, height);
}
}
public override getActionViewItem(action: Action): IActionViewItem | undefined {