From 567b5b605bf57f305197621d0ddc5f2b8c23ed64 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Mon, 28 Mar 2022 00:15:44 +1100
Subject: Make auto-mode move-across/down prioritise higher dCount

---
 src/App.vue | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index 725f630..295bceb 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -98,7 +98,7 @@ function getReverseAction(action: Action): Action | null {
 		case 'expand to view':
 			return 'expand parent bar';
 		case 'expand parent bar':
-			return 'expand';
+			return 'expand to view';
 	}
 }
 
@@ -430,11 +430,12 @@ export default defineComponent({
 				switch (action){
 					case 'move across':
 						let siblings = node.parent!.children.filter(n => n != node);
-						this.setLastFocused(siblings[Math.floor(Math.random() * siblings.length)]);
+						let siblingWeights = siblings.map(n => n.dCount + 1);
+						this.setLastFocused(siblings[randWeightedChoice(siblingWeights)]);
 						break;
 					case 'move down':
-						let idx = Math.floor(Math.random() * node.children.length);
-						this.setLastFocused(node.children[idx]);
+						let childWeights = node.children.map(n => n.dCount + 1);
+						this.setLastFocused(node.children[randWeightedChoice(childWeights)]);
 						break;
 					case 'move up':
 						this.setLastFocused(node.parent!);
-- 
cgit v1.2.3

