From d96a9fa286f5e63fc107841c5646418c3e21af34 Mon Sep 17 00:00:00 2001
From: u7327620 <u7327620@anu.edu.au>
Date: Sun, 20 Oct 2024 19:51:35 +1100
Subject: [PATCH] messages: Show headers if is_search_narrow().

Previously, when text searching, messages appear
adjacently under the same heading, this can be confusing since they
appear sequentially but there may be messages inbetween that don't meet
the search criteria. Fixes part of #1550.
---
 zulipterminal/ui_tools/messages.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/zulipterminal/ui_tools/messages.py b/zulipterminal/ui_tools/messages.py
index eb44b00de0..eeaa7eea8e 100644
--- a/zulipterminal/ui_tools/messages.py
+++ b/zulipterminal/ui_tools/messages.py
@@ -120,8 +120,14 @@ def need_recipient_header(self) -> bool:
             return False
         if len(self.model.narrow) == 2 and self.model.narrow[1][0] == "topic":
             return False
+
         if self.model.is_search_narrow():
-            return True
+            if len(self.model.narrow) == 1:
+                return True
+            if len(self.model.narrow) == 2:
+                return not self.message["type"] == "private"
+            if len(self.model.narrow) == 3:
+                return not self.model.narrow[1][0] == "topic"
 
         if self.model.is_search_narrow():
             if len(self.model.narrow) == 1: