Skip to content

Commit 6e37770

Browse files
authored
Cannot read properties of undefined (reading 'layout') (microsoft#213797)
Fixes microsoft#212235
1 parent c061693 commit 6e37770

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/vs/workbench/contrib/remote/browser/tunnelView.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ export class TunnelPanel extends ViewPane {
750750
static readonly TITLE: ILocalizedString = nls.localize2('remote.tunnel', "Ports");
751751

752752
private panelContainer: HTMLElement | undefined;
753-
private table!: WorkbenchTable<ITunnelItem>;
753+
private table: WorkbenchTable<ITunnelItem> | undefined;
754754
private readonly tableDisposables: DisposableStore = this._register(new DisposableStore());
755755
private tunnelTypeContext: IContextKey<TunnelType>;
756756
private tunnelCloseableContext: IContextKey<boolean>;
@@ -830,7 +830,7 @@ export class TunnelPanel extends ViewPane {
830830
updateActions();
831831
this.registerPrivacyActions();
832832
this.createTable();
833-
this.table.layout(this.height, this.width);
833+
this.table?.layout(this.height, this.width);
834834
}
835835
}));
836836
}
@@ -913,7 +913,7 @@ export class TunnelPanel extends ViewPane {
913913
this.tableDisposables.add(this.table.onDidFocus(() => this.tunnelViewFocusContext.set(true)));
914914
this.tableDisposables.add(this.table.onDidBlur(() => this.tunnelViewFocusContext.set(false)));
915915

916-
const rerender = () => this.table.splice(0, Number.POSITIVE_INFINITY, this.viewModel.all);
916+
const rerender = () => this.table?.splice(0, Number.POSITIVE_INFINITY, this.viewModel.all);
917917

918918
rerender();
919919
let lastPortCount = this.portCount;
@@ -927,7 +927,7 @@ export class TunnelPanel extends ViewPane {
927927
}));
928928

929929
this.tableDisposables.add(this.table.onMouseClick(e => {
930-
if (this.hasOpenLinkModifier(e.browserEvent)) {
930+
if (this.hasOpenLinkModifier(e.browserEvent) && this.table) {
931931
const selection = this.table.getSelectedElements();
932932
if ((selection.length === 0) ||
933933
((selection.length === 1) && (selection[0] === e.element))) {
@@ -959,11 +959,11 @@ export class TunnelPanel extends ViewPane {
959959
widgetContainer.classList.add('highlight');
960960
if (!e) {
961961
// When we are in editing mode for a new forward, rather than updating an existing one we need to reveal the input box since it might be out of view.
962-
this.table.reveal(this.table.indexOf(this.viewModel.input));
962+
this.table?.reveal(this.table.indexOf(this.viewModel.input));
963963
}
964964
} else {
965965
if (e && (e.tunnel.tunnelType !== TunnelType.Add)) {
966-
this.table.setFocus(this.lastFocus);
966+
this.table?.setFocus(this.lastFocus);
967967
}
968968
this.focus();
969969
}
@@ -983,7 +983,7 @@ export class TunnelPanel extends ViewPane {
983983

984984
override focus(): void {
985985
super.focus();
986-
this.table.domFocus();
986+
this.table?.domFocus();
987987
}
988988

989989
private onFocusChanged(event: ITableEvent<ITunnelItem>) {
@@ -1045,7 +1045,7 @@ export class TunnelPanel extends ViewPane {
10451045
const node: TunnelItem | undefined = event.element;
10461046

10471047
if (node) {
1048-
this.table.setFocus([this.table.indexOf(node)]);
1048+
this.table?.setFocus([this.table.indexOf(node)]);
10491049
this.tunnelTypeContext.set(node.tunnelType);
10501050
this.tunnelCloseableContext.set(!!node.closeable);
10511051
this.tunnelPrivacyContext.set(node.privacy.id);
@@ -1062,7 +1062,7 @@ export class TunnelPanel extends ViewPane {
10621062
this.contextMenuService.showContextMenu({
10631063
menuId: MenuId.TunnelContext,
10641064
menuActionOptions: { shouldForwardArgs: true },
1065-
contextKeyService: this.table.contextKeyService,
1065+
contextKeyService: this.table?.contextKeyService,
10661066
getAnchor: () => event.anchor,
10671067
getActionViewItem: (action) => {
10681068
const keybinding = this.keybindingService.lookupKeybinding(action.id);
@@ -1073,7 +1073,7 @@ export class TunnelPanel extends ViewPane {
10731073
},
10741074
onHide: (wasCancelled?: boolean) => {
10751075
if (wasCancelled) {
1076-
this.table.domFocus();
1076+
this.table?.domFocus();
10771077
}
10781078
},
10791079
getActionsContext: () => node?.strip(),
@@ -1093,7 +1093,7 @@ export class TunnelPanel extends ViewPane {
10931093
this.height = height;
10941094
this.width = width;
10951095
super.layoutBody(height, width);
1096-
this.table.layout(height, width);
1096+
this.table?.layout(height, width);
10971097
}
10981098
}
10991099

0 commit comments

Comments
 (0)