Nicer fix for showing cwd in tab titles

This commit is contained in:
Kovid Goyal
2022-07-26 12:33:53 +05:30
parent f6a1eb19d7
commit 352c07987b
4 changed files with 11 additions and 17 deletions

View File

@@ -178,28 +178,14 @@ def template_has_field(template: str, field: str) -> bool:
return False
class TabCWD:
def __init__(self, tab_ref: 'ReferenceType[Tab]'):
self.tab_ref = tab_ref
self.saved_val: Optional[str] = None
def __str__(self) -> str:
if self.saved_val is None:
tab = self.tab_ref()
self.saved_val = (tab.get_cwd_of_active_window() or '') if tab else ''
return self.saved_val
def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int) -> None:
tcwd = TabCWD(tab.tab_ref)
data = {
'index': index,
'layout_name': tab.layout_name,
'num_windows': tab.num_windows,
'num_window_groups': tab.num_window_groups,
'title': tab.title,
'cwd': tcwd,
'tab': tab.tab_ref(),
}
ColorFormatter.draw_data = draw_data
ColorFormatter.tab_data = tab
@@ -209,7 +195,7 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int)
'num_windows': tab.num_windows,
'num_window_groups': tab.num_window_groups,
'title': tab.title,
'cwd': tcwd,
'tab': tab.tab_ref(),
'fmt': Formatter,
'sup': SupSub(data),
'sub': SupSub(data, True),