From afebea863548a0512c4969b4a588726460191901 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 12 Apr 2022 12:53:59 +0530 Subject: [PATCH] --tab-title=current should respect any override title set on the tab --- kitty/launch.py | 2 +- kitty/tabs.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kitty/launch.py b/kitty/launch.py index 7a35bb786..f4917b06d 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -353,7 +353,7 @@ def launch( opts.window_title = active.title if active else None if opts.tab_title == 'current': atab = boss.active_tab - opts.tab_title = atab.title if atab else None + opts.tab_title = atab.effective_title if atab else None if opts.os_window_title == 'current': tm = boss.active_tab_manager opts.os_window_title = get_os_window_title(tm.os_window_id) if tm else None diff --git a/kitty/tabs.py b/kitty/tabs.py index 82d29d73c..dc450cb3b 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -10,7 +10,7 @@ from operator import attrgetter from time import monotonic from typing import ( Any, Deque, Dict, Generator, Iterable, Iterator, List, NamedTuple, - Optional, Pattern, Sequence, Set, Tuple, Union, cast + Optional, Pattern, Sequence, Set, Tuple, Union ) from .borders import Border, Borders @@ -210,7 +210,12 @@ class Tab: # {{{ @property def title(self) -> str: - return cast(str, getattr(self.active_window, 'title', appname)) + w = self.active_window + return w.title if w else appname + + @property + def effective_title(self) -> str: + return self.name or self.title @property def number_of_windows_with_running_programs(self) -> int: @@ -686,7 +691,7 @@ class Tab: # {{{ if field == 'id': return bool(pat.pattern == str(self.id)) if field == 'title': - return pat.search(self.name or self.title) is not None + return pat.search(self.effective_title) is not None return False def __iter__(self) -> Iterator[Window]: @@ -709,7 +714,7 @@ class Tab: # {{{ self.windows = WindowList(self) def __repr__(self) -> str: - return f'Tab(title={self.name or self.title}, id={hex(id(self))})' + return f'Tab(title={self.effective_title}, id={hex(id(self))})' def make_active(self) -> None: tm = self.tab_manager_ref()