Merge pull request #5940 from Textualize/fix-textarea-select

Fix textarea select
This commit is contained in:
Will McGugan
2025-07-09 10:03:55 +01:00
committed by GitHub
5 changed files with 186 additions and 2 deletions

View File

@@ -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 https://github.com/Textualize/textual/pull/5940
## [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

View File

@@ -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/"

View File

@@ -1174,7 +1174,7 @@ TextArea {
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
),
(

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -4347,3 +4347,28 @@ def test_snapshot_scroll(snap_compare):
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",
),
)