diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f76de662..fd3cf7bc9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.61.1] - 202405-19 + +### Fixed + +- Fixed auto grid columns ignoring gutter https://github.com/Textualize/textual/issues/4522 + ## [0.61.0] - 2024-05-18 ### Added @@ -1966,6 +1972,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040 - New handler system for messages that doesn't require inheritance - Improved traceback handling +[0.61.1]: https://github.com/Textualize/textual/compare/v0.61.0...v0.61.1 [0.61.0]: https://github.com/Textualize/textual/compare/v0.60.1...v0.61.0 [0.60.1]: https://github.com/Textualize/textual/compare/v0.60.0...v0.60.1 [0.60.0]: https://github.com/Textualize/textual/compare/v0.59.0...v0.60.0 diff --git a/pyproject.toml b/pyproject.toml index 4676157641..e1f10a2b06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual" -version = "0.61.0" +version = "0.61.1" homepage = "https://github.com/Textualize/textual" repository = "https://github.com/Textualize/textual" documentation = "https://textual.textualize.io/" diff --git a/src/textual/fuzzy.py b/src/textual/fuzzy.py index 236f83e32c..b09f8e1604 100644 --- a/src/textual/fuzzy.py +++ b/src/textual/fuzzy.py @@ -114,52 +114,3 @@ def highlight(self, candidate: str) -> Text: text.stylize(self._match_style, offset, offset + 1) return text - - -if __name__ == "__main__": - from itertools import permutations - from string import ascii_lowercase - from time import monotonic - - from rich import print - from rich.rule import Rule - - matcher = Matcher("foo.bar") - print(Rule()) - print("Query is:", matcher.query) - print("Rule is:", matcher.query_pattern) - print(Rule()) - candidates = ( - "foo.bar", - " foo.bar ", - "Hello foo.bar world", - "f o o . b a r", - "f o o .bar", - "foo. b a r", - "Lots of text before the foo.bar", - "foo.bar up front and then lots of text afterwards", - "This has an o in it but does not have a match", - "Let's find one obvious match. But blat around always roughly.", - ) - results = sorted( - [ - (matcher.match(candidate), matcher.highlight(candidate)) - for candidate in candidates - ], - key=lambda pair: pair[0], - reverse=True, - ) - for score, highlight in results: - print(f"{score:.15f} '", highlight, "'", sep="") - print(Rule()) - - RUNS = 5 - candidates = [ - "".join(permutation) for permutation in permutations(ascii_lowercase[:10]) - ] - matcher = Matcher(ascii_lowercase[:10]) - start = monotonic() - for _ in range(RUNS): - for candidate in candidates: - _ = matcher.match(candidate) - print(f"{RUNS * len(candidates)} matches in {monotonic() - start:.5f} seconds") diff --git a/src/textual/layouts/grid.py b/src/textual/layouts/grid.py index 077b905074..2274e1a8f7 100644 --- a/src/textual/layouts/grid.py +++ b/src/textual/layouts/grid.py @@ -206,14 +206,15 @@ def apply_height_limits(widget: Widget, height: int) -> int: if widget.styles.row_span != 1: continue column_width = columns[column][1] + gutter_width, gutter_height = widget.styles.gutter.totals widget_height = apply_height_limits( widget, widget.get_content_height( size, viewport, - column_width, + column_width - gutter_width, ) - + widget.styles.gutter.height, + + gutter_height, ) height = max(height, widget_height) row_scalars[row] = Scalar.from_number(height) diff --git a/tests/snapshot_tests/snapshot_apps/grid_gutter.py b/tests/snapshot_tests/snapshot_apps/grid_gutter.py new file mode 100644 index 0000000000..73ac562632 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/grid_gutter.py @@ -0,0 +1,42 @@ +from rich.markdown import Markdown +from textual.app import App, ComposeResult +from textual.containers import Grid, Vertical +from textual.widgets import Label, TabbedContent, TabPane + + +class FooApp(App): + TITLE = "Demonstrator" + + CSS = """ + Screen { + align: center middle; + } + + #root { + width: 60; + height: 20; + border: solid $accent; + } + .info-container { + grid-rows: auto; + } + .value { + padding: 0 2; + border: tall $background; + } + """ + + def compose(self) -> ComposeResult: + with Vertical(id="root"): + with TabbedContent(): + with TabPane("Information"): + with Grid(classes="info-container"): + yield Label(Markdown(long_text()), classes="value") + + +def long_text() -> str: + return 'aaa naa aaaaa aaa aaaan, aaa\naaa, aaaa?", aa aaa aaaaanaaa *anaaaaaaana* aaaaaaaa aaaaaana aaa aaaaa aa\naaa, aa *aaaaaaaaa* aaa aaaa, "aaaa, an *aaaa* aaa aaaa, a aa". "aaaa, naa\naaaaaaaaaaa, aaa a aaaa aaaaaanaa aaaa aa a aaa!", aaa anaaaa, aaaaa\naaaaaaaa aanaaaaa. "Na! aaa naa. aaaaa. aa aaaaa naa. aaaaa aa na aaa.",\naaa aaaaaaaa aaaanaaaaa DONE.\n' + + +if __name__ == "__main__": + FooApp().run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 449d239533..f168fc2a92 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -1259,3 +1259,8 @@ def test_dynamic_bindings(snap_compare): assert snap_compare( SNAPSHOT_APPS_DIR / "dynamic_bindings.py", press=["a", "b", "c"] ) + + +def test_grid_gutter(snap_compare): + # https://github.com/Textualize/textual/issues/4522 + assert snap_compare(SNAPSHOT_APPS_DIR / "grid_gutter.py")