From 748548c8155fe9a8db8e8c1f3f45d0c3e93a5744 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 9 Jul 2025 09:25:02 +0100 Subject: [PATCH 1/3] bump --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- src/textual/widgets/_text_area.py | 2 +- tests/snapshot_tests/test_snapshots.py | 25 +++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa51152cb9..bf608778e6 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/). +## [3.7.1] - 2025-07-09 + +### Fixed + +- Fixed broken text selection with soft_wrap=False + ## [3.7.0] - 2025-07-07 ### Added @@ -2954,6 +2960,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 +[3.7.1]: https://github.com/Textualize/textual/compare/v3.7.0...v3.7.1 [3.7.0]: https://github.com/Textualize/textual/compare/v3.6.0...v3.7.0 [3.6.0]: https://github.com/Textualize/textual/compare/v3.5.0...v3.6.0 [3.5.0]: https://github.com/Textualize/textual/compare/v3.4.0...v3.5.0 diff --git a/pyproject.toml b/pyproject.toml index 2bbcab0f51..b98abcddc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual" -version = "3.7.0" +version = "3.7.1" homepage = "https://github.com/Textualize/textual" repository = "https://github.com/Textualize/textual" documentation = "https://textual.textualize.io/" diff --git a/src/textual/widgets/_text_area.py b/src/textual/widgets/_text_area.py index 338d9765bd..771f441581 100644 --- a/src/textual/widgets/_text_area.py +++ b/src/textual/widgets/_text_area.py @@ -1174,7 +1174,7 @@ def render_line(self, y: int) -> Strip: absolute_y, ( selection - if selection.contains_line(absolute_y) + if selection.contains_line(absolute_y) or self.soft_wrap else selection.end[0] == absolute_y ), ( diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index a2b609c9a8..e1a99d61f4 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -4347,3 +4347,28 @@ def on_mount(self) -> None: self.query_one("#my-container").scroll_to(0, 3) assert snap_compare(ScrollKeylineApp()) + + +def test_textarea_select(snap_compare): + """Regression test for https://github.com/Textualize/textual/issues/5939 + + You should see three lines selected, starting from the third character with the curser ending at the fifth character. + + """ + + class TextApp(App): + def compose(self) -> ComposeResult: + yield TextArea("Hello, World! " * 100) + + snap_compare( + TextApp(), + press=( + "right", + "right", + "shift+down", + "shift+down", + "shift+down", + "shift+right", + "shift+right", + ), + ) From 991082c1e4c6b0003da6ed8f214a879a71490468 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 9 Jul 2025 09:25:46 +0100 Subject: [PATCH 2/3] snapshot --- .../test_snapshots/test_textarea_select.svg | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/snapshot_tests/__snapshots__/test_snapshots/test_textarea_select.svg diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_textarea_select.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_textarea_select.svg new file mode 100644 index 0000000000..984cc0ec07 --- /dev/null +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_textarea_select.svg @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TextApp + + + + + + + + + + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!  +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!  +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!  +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        +Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!        + + +▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + + From 2aba6199b4393b265b59fbb4039429941c888756 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 9 Jul 2025 09:26:29 +0100 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf608778e6..99d93ccc06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Fixed broken text selection with soft_wrap=False +- Fixed broken text selection with soft_wrap=False https://github.com/Textualize/textual/pull/5940 ## [3.7.0] - 2025-07-07