From 6edf3fe12a7c895eb55292281eac497377128fd2 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sun, 22 May 2022 21:53:23 +1000
Subject: Make ancestor-hiding during searches extend halfway to active-root

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

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index 1dd0b93..e1da1f2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -384,19 +384,18 @@ export default defineComponent({
 					setTimeout(() => this.expandToNode(name), this.uiOpts.tileChgDuration);
 					return;
 				}
-				// Attempt expand-to-view on an ancestor
+				// Attempt expand-to-view on an ancestor halfway to the active root
 				if (layoutNode == this.activeRoot){
 					console.log('Screen too small to expand active root');
 					this.modeRunning = false;
 					return;
 				}
-				const MAX_ANCESTOR_DIST = 5;
-				for (let i = 0; i < MAX_ANCESTOR_DIST; i++){
-					if (layoutNode.parent! == this.activeRoot){
-						break;
-					}
+				let ancestorChain = [layoutNode];
+				while (layoutNode.parent! != this.activeRoot){
 					layoutNode = layoutNode.parent!;
+					ancestorChain.push(layoutNode);
 				}
+				layoutNode = ancestorChain[Math.floor((ancestorChain.length - 1) / 2)]
 				this.onNonleafClickHeld(layoutNode);
 				setTimeout(() => this.expandToNode(name), this.uiOpts.tileChgDuration);
 			});
-- 
cgit v1.2.3

