MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / insertNode

Function insertNode

frontend/layout/lib/layoutTree.ts:279–297  ·  view source on GitHub ↗
(layoutState: LayoutTreeState, action: LayoutTreeInsertNodeAction)

Source from the content-addressed store, hash-verified

277}
278
279export function insertNode(layoutState: LayoutTreeState, action: LayoutTreeInsertNodeAction) {
280 if (!action?.node) {
281 console.error("insertNode cannot run, no insert node action provided");
282 return;
283 }
284 if (!layoutState.rootNode) {
285 layoutState.rootNode = action.node;
286 } else {
287 const insertLoc = findNextInsertLocation(layoutState.rootNode, DEFAULT_MAX_CHILDREN);
288 addChildAt(insertLoc.node, insertLoc.index, action.node);
289 if (action.magnified) {
290 layoutState.magnifiedNodeId = action.node.id;
291 layoutState.focusedNodeId = action.node.id;
292 }
293 }
294 if (action.focused) {
295 layoutState.focusedNodeId = action.node.id;
296 }
297}
298
299export function insertNodeAtIndex(layoutState: LayoutTreeState, action: LayoutTreeInsertNodeAtIndexAction) {
300 if (!action?.node || !action?.indexArr) {

Callers 1

treeReducerMethod · 0.90

Calls 2

findNextInsertLocationFunction · 0.90
addChildAtFunction · 0.90

Tested by

no test coverage detected