summaryrefslogtreecommitdiff
path: root/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'node.c')
-rw-r--r--node.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/node.c b/node.c
index 5ae0ea7..7898c3c 100644
--- a/node.c
+++ b/node.c
@@ -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;
+}