From 412cd30cd2fe4feeff853f99f24bd94ef51b8bf3 Mon Sep 17 00:00:00 2001 From: mcrmck Date: Sun, 22 Mar 2026 13:06:30 -0400 Subject: [PATCH] Fix synthetic '+' tab rendering and make it always-visible as a new-tab button - Skip user tab_title_template for synthetic tabs (tab_id < 0) so custom templates referencing layout_name no longer produce '? +' during drags - Always append the '+' drop indicator to tab_bar_data (not only during window drags), making it a persistent clickable new-tab button - Handle click on the '+' tab (tab_id == -1) in the tab bar mouse handler by calling new_tab() on left-button release --- kitty/tab_bar.py | 2 ++ kitty/tabs.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kitty/tab_bar.py b/kitty/tab_bar.py index d42da165b..d52bfa389 100644 --- a/kitty/tab_bar.py +++ b/kitty/tab_bar.py @@ -265,6 +265,8 @@ safe_builtins = { def apply_title_template(draw_data: DrawData, tab: TabBarData, index: int, max_title_length: int = 0) -> str: + if tab.tab_id < 0: + return tab.title # synthetic tab — render title literally, skip user template ta = TabAccessor(tab.tab_id) data = { 'index': index, diff --git a/kitty/tabs.py b/kitty/tabs.py index 0b69bbc53..39815262a 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -1607,15 +1607,13 @@ class TabManager: # {{{ dragged_tab_id, drag_started = get_tab_being_dragged()[:2] if drag_started: tab_being_dragged_from_here = self.tab_for_id(dragged_tab_id) is not None - window_drag_active = get_window_being_dragged()[1] if self.tab_being_dropped is None: wdtt = self.window_drag_target_tab_id if tab_being_dragged_from_here: tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar if t.id != dragged_tab_id) else: tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar) - if window_drag_active: - tabs = tabs + (self._new_tab_drop_indicator(),) + tabs = tabs + (self._new_tab_drop_indicator(),) return tabs tmap = {t.id:t for t in self.tabs} at = self.active_tab @@ -1746,7 +1744,12 @@ class TabManager: # {{{ request_callback_with_thumbnail("start_tab_drag", self.os_window_id) return - tab = self.tab_for_id(self.tab_bar.tab_id_at(int(x))) + tab_id_at_x = self.tab_bar.tab_id_at(int(x)) + if tab_id_at_x == -1: + if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE: + self.new_tab() + return + tab = self.tab_for_id(tab_id_at_x) now = monotonic() if tab is None: if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_mouse_events) > 2: