From d81454cd915a9786a3b8b9d38f0cf3f0e93d0b06 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Sun, 9 Mar 2025 15:31:04 +1100
Subject: launcher: fix actions not clearing in math mode

---
 src/modules/launcher/index.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/modules/launcher/index.tsx')

diff --git a/src/modules/launcher/index.tsx b/src/modules/launcher/index.tsx
index f3a1e53..3f8645e 100644
--- a/src/modules/launcher/index.tsx
+++ b/src/modules/launcher/index.tsx
@@ -22,7 +22,7 @@ const getPrettyMode = (mode: Mode) => {
     return mode;
 };
 
-const isAction = (text: string) => text.startsWith(config.actionPrefix.get());
+const isAction = (text: string, action: string = "") => text.startsWith(config.actionPrefix.get() + action);
 
 const SearchBar = ({ mode, entry }: { mode: Variable<Mode>; entry: Widget.Entry }) => (
     <box className="search-bar">
@@ -127,7 +127,10 @@ export default class Launcher extends PopupWindow {
         });
 
         // Clear search on hide if not in math mode or creating a todo
-        this.connect("hide", () => mode.get() !== "math" && !entry.text.startsWith(">todo") && entry.set_text(""));
+        this.connect("hide", () => {
+            if ((mode.get() !== "math" || isAction(entry.get_text())) && !isAction(entry.get_text(), "todo"))
+                entry.set_text("");
+        });
     }
 
     open(mode: Mode) {
-- 
cgit v1.2.3-freya

