Fix new tab bug that would remove terminal block (#1006)

This commit is contained in:
Evan Simkowitz 2024-10-10 16:33:48 -04:00 committed by GitHub
parent bd5e6223f3
commit a109ccfec8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -43,7 +43,7 @@ export function withLayoutTreeStateAtomFromTab(tabAtom: Atom<Tab>): WritableLayo
waveObjVal.magnifiednodeid = value.magnifiedNodeId;
waveObjVal.focusednodeid = value.focusedNodeId;
waveObjVal.leaforder = value.leafOrder; // only set leaforder, never get it, since this value is driven by the frontend
waveObjVal.pendingbackendactions = value.pendingBackendActions?.length
waveObjVal.pendingbackendactions = value?.pendingBackendActions?.length
? value.pendingBackendActions
: undefined;
set(generationAtom, value.generation);

View File

@ -389,7 +389,7 @@ export class LayoutModel {
) {
this.treeState = treeState;
if (this.treeState.pendingBackendActions?.length) {
if (this.treeState?.pendingBackendActions?.length) {
const actions = this.treeState.pendingBackendActions;
this.treeState.pendingBackendActions = undefined;
for (const action of actions) {
@ -631,7 +631,7 @@ export class LayoutModel {
// Remove duplicates and stale entries from focus stack.
const newFocusedNodeIdStack: string[] = [];
for (const id of this.focusedNodeIdStack) {
if (leafOrder.find((leafEntry) => leafEntry.nodeid === id) && !newFocusedNodeIdStack.includes(id))
if (leafOrder.find((leafEntry) => leafEntry?.nodeid === id) && !newFocusedNodeIdStack.includes(id))
newFocusedNodeIdStack.push(id);
}
this.focusedNodeIdStack = newFocusedNodeIdStack;
@ -640,7 +640,7 @@ export class LayoutModel {
if (!this.treeState.focusedNodeId) {
if (this.focusedNodeIdStack.length > 0) {
this.treeState.focusedNodeId = this.focusedNodeIdStack.shift();
} else {
} else if (leafOrder.length > 0) {
// If no nodes are in the stack, use the top left node in the layout.
this.treeState.focusedNodeId = leafOrder[0].nodeid;
}