home · contact · privacy
Depend tainting in _WindowClientManager.update re prompts on actual changes having...
authorChristian Heller <c.heller@plomlompom.de>
Sun, 10 Aug 2025 12:02:29 +0000 (14:02 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 10 Aug 2025 12:02:29 +0000 (14:02 +0200)
ircplom/client_tui.py

index 3916fb40735bafc75d0996ded9b7f8861d71a7a1..1b55f87a7e078e2ca2f6494af428cbe2a6499f77 100644 (file)
@@ -96,17 +96,16 @@ class _ClientWindowsManager:
         for stream in (STREAM_SERVER, STREAM_RAW):
             self._new_window(stream)
 
-    def _if_privmsg_update_prefix(self, win: _ClientWindow) -> None:
-        if isinstance(win, _PrivmsgWindow):
-            win.prompt.update_prefix(
-                    **{k: getattr(self, k)
-                       for k in _PrivmsgPromptWidget.prefix_update_keys()})
+    def _prompt_update(self, win: _PrivmsgWindow) -> None:
+        to_set = win.prompt.prefix_update_keys()
+        win.prompt.update_prefix(**{k: getattr(self, k) for k in to_set})
 
     def _new_window(self, stream: str) -> _ClientWindow:
         win_class = (_PrivmsgWindow if stream[0:1] != STREAM_PREFIX_META
                      else _ClientWindow)
         win = self._tui_new_window(win_class, stream=stream)
-        self._if_privmsg_update_prefix(win)
+        if isinstance(win, _PrivmsgWindow):
+            self._prompt_update(win)
         self.windows += [win]
         return win
 
@@ -130,8 +129,10 @@ class _ClientWindowsManager:
             setattr(self, k, v)
         tainteds = False
         if _PrivmsgPromptWidget.prefix_update_keys() & set(kwargs.keys()):
-            for win in self.windows:
-                self._if_privmsg_update_prefix(win)
+            for win in [w for w in self.windows
+                        if isinstance(w, _PrivmsgWindow)]:
+                self._prompt_update(win)
+                tainteds |= win.prompt.tainted
             tainteds = True
         return tainteds