From 09c9d9a3fd96b6e959634cc669ebe2640d478655 Mon Sep 17 00:00:00 2001 From: gholk Date: Sat, 8 Mar 2025 12:58:07 +0800 Subject: [PATCH] Fix TabHistory completion error message Sometimes TabValue history is undefined and flattenTree(undefined) will throw an error. The error will be caught but we can do more elegant. --- src/completions/TabHistory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/completions/TabHistory.ts b/src/completions/TabHistory.ts index b557894a..ea61d32a 100644 --- a/src/completions/TabHistory.ts +++ b/src/completions/TabHistory.ts @@ -127,7 +127,9 @@ export class TabHistoryCompletionSource extends Completions.CompletionSourceFuse let history = await browserBg.sessions.getTabValue(tab[0].id, "history") if (!history) history = { list: [] } const tree = this.makeTree(history["list"]) - history["list"] = this.flattenTree(tree[0]).reverse() + if (tree.length > 0) { + history["list"] = this.flattenTree(tree[0]).reverse() + } this.addIndicies(history["list"]) this.addFormatTimeSpan(history["list"])