mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-20 15:12:37 +00:00
Fix #10810
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
This commit is contained in:
parent
3e4ffc1098
commit
bdbf9f5af5
3 changed files with 32 additions and 3 deletions
|
|
@ -125,6 +125,8 @@ Detailed list of changes
|
|||
0.50.1 [unreleased]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- Vertical tab bar: Fix clicking the blank line below a tab not activating the tab (:iss:`10810`)
|
||||
|
||||
- :doc:`Custom shaders <custom-shaders>`: Add ``screen-shake`` and
|
||||
``screen-shake-random`` shaders that shake the window in which a bell occurs,
|
||||
for example, to shake the window when a shell command fails
|
||||
|
|
|
|||
|
|
@ -811,6 +811,8 @@ class TabBar:
|
|||
self.data_buffer_size = 0
|
||||
self.blank_rects: tuple[Border, ...] = ()
|
||||
self.tab_extents: Sequence[TabExtent] = ()
|
||||
# Number of blank lines left after each tab in a vertical tab bar
|
||||
self.vertical_tab_spacing = 0
|
||||
self.window_drop_insert_before: int | None = None
|
||||
self.tab_drop_insert_before: int | None = None
|
||||
self.laid_out_once = False
|
||||
|
|
@ -1164,6 +1166,7 @@ class TabBar:
|
|||
s = self.screen
|
||||
self.last_laid_out_tabs = data
|
||||
self.tab_extents = ()
|
||||
self.vertical_tab_spacing = 0
|
||||
s.cursor.x = s.cursor.y = 0
|
||||
s.erase_in_display(2, False)
|
||||
if not data:
|
||||
|
|
@ -1255,6 +1258,7 @@ class TabBar:
|
|||
s.cursor.fg = as_rgb(0xFF0000)
|
||||
s.draw('…')
|
||||
self.tab_extents = tuple(cr)
|
||||
self.vertical_tab_spacing = spacing
|
||||
self.draw_drop_insert_marker()
|
||||
return self._update_edge_defaults(True)
|
||||
|
||||
|
|
@ -1310,6 +1314,12 @@ class TabBar:
|
|||
for te in self.tab_extents:
|
||||
if te.contains(x, y):
|
||||
return te.tab_id
|
||||
if self.is_vertical and self.vertical_tab_spacing:
|
||||
# The blank line after a tab belongs to it, so that clicking
|
||||
# just below a tab's title still activates the tab.
|
||||
for te in self.tab_extents:
|
||||
if te.tab_id > 0 and te.x.start <= x <= te.x.end and te.y.end < y <= te.y.end + self.vertical_tab_spacing:
|
||||
return te.tab_id
|
||||
return 0
|
||||
|
||||
def drag_axis_coordinate(self, x: int, y: int) -> int:
|
||||
|
|
|
|||
|
|
@ -285,18 +285,35 @@ class TestTabBar(BaseTest):
|
|||
|
||||
def test_vertical_tab_bar_tab_spacing(self) -> None:
|
||||
# a blank line is left between tabs while there is room for it, but not
|
||||
# above the first tab, and the gaps are not part of any tab's extent so
|
||||
# clicking one activates nothing
|
||||
# above the first tab. The gaps are not part of any tab's drawn extent,
|
||||
# but for clicks the gap after a tab belongs to that tab.
|
||||
tb = self.vertical_tab_bar(num_tabs=3)
|
||||
self.ae(self.screen_lines(tb)[:6], ['t0', '', 't1', '', 't2', ''])
|
||||
self.ae(tuple(te.y for te in tb.tab_extents), (CellRange(0, 0), CellRange(2, 2), CellRange(4, 4)))
|
||||
self.ae(tb.tab_id_at(5, 10), 1)
|
||||
self.ae(tb.tab_id_at(5, 30), 0)
|
||||
self.ae(tb.tab_id_at(5, 30), 1)
|
||||
self.ae(tb.tab_id_at(5, 50), 2)
|
||||
self.ae(tb.tab_id_at(5, 90), 3)
|
||||
self.ae(tb.tab_id_at(5, 110), 3)
|
||||
self.ae(tb.tab_id_at(5, 130), 0)
|
||||
|
||||
# the gap uses the tab bar background, not the neighbouring tab's
|
||||
self.ae(int(tb.screen.line(1).cursor_from(0).bg), 0)
|
||||
|
||||
# the gap above the new tab button belongs to the tab above it, while
|
||||
# the line below the button is empty tab bar space
|
||||
tb = self.vertical_tab_bar(num_tabs=2)
|
||||
with patch('kitty.tab_bar.update_tab_bar_edge_colors', return_value=None), patch('kitty.tab_bar.get_boss', return_value=DummyBoss()):
|
||||
tb.update(tuple(tb.last_laid_out_tabs) + (TabBarData(title='+'),))
|
||||
self.ae(tuple(te.tab_id for te in tb.tab_extents)[:2], (1, 2))
|
||||
self.ae(tb.tab_id_at(5, 70), 2)
|
||||
self.assertLess(tb.tab_id_at(5, 90), 0)
|
||||
self.ae(tb.tab_id_at(5, 110), 0)
|
||||
|
||||
# no gaps, no extra hit area
|
||||
tb = self.vertical_tab_bar(num_tabs=8, height=160)
|
||||
self.ae(tb.tab_id_at(5, 150), 8)
|
||||
|
||||
# spacing applies between multi-line tabs too
|
||||
tb = self.vertical_tab_bar(num_tabs=2, tab_title_max_lines=2, tab_title_template='{title}\\nbr')
|
||||
self.ae(self.screen_lines(tb)[:6], ['t0', 'br', '', 't1', 'br', ''])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue