--tab-title=current should respect any override title set on the tab

This commit is contained in:
Kovid Goyal 2022-04-12 12:53:59 +05:30
parent 5d76cfb578
commit afebea8635
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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()