diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-05 16:11:01 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-05 16:11:01 -0500 |
commit | 8944eb64682f626f76b9b204a58afc8fa5d0a522 (patch) | |
tree | a82fabd9a7c0e90d72a1d3368935ecc54cafa575 /node.c | |
parent | f80661e0958c1fa70b2eea9dc2a9b89e86c802d3 (diff) |
fix some little problems with the file selector
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -417,11 +417,12 @@ static void node_split(Ted *ted, Node *node, bool vertical) { } } -// swap to the other side of a split -static void node_split_swap(Ted *ted) { +static void node_split_switch(Ted *ted) { assert(ted->active_node); u16 active_node_idx = (u16)(ted->active_node - ted->nodes); - Node *parent = &ted->nodes[node_parent(ted, active_node_idx)]; + i32 parent_idx = node_parent(ted, active_node_idx); + if (parent_idx < 0) return; + Node *parent = &ted->nodes[parent_idx]; if (parent) { if (parent->split_a == active_node_idx) { ted_node_switch(ted, &ted->nodes[parent->split_b]); @@ -430,3 +431,14 @@ static void node_split_swap(Ted *ted) { } } } + +static void node_split_swap(Ted *ted) { + assert(ted->active_node); + u16 active_node_idx = (u16)(ted->active_node - ted->nodes); + i32 parent_idx = node_parent(ted, active_node_idx); + if (parent_idx < 0) return; + Node *parent = &ted->nodes[parent_idx]; + u16 temp = parent->split_a; + parent->split_a = parent->split_b; + parent->split_b = temp; +} |