mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Fixed `TreeNode.collapse` and `TreeNode.collapse_all` not posting a `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535
|
||||
- Fixed `TreeNode.toggle` and `TreeNode.toggle_all` not posting a `Tree.NodeExpanded` or `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535
|
||||
- `footer--description` component class was being ignored https://github.com/Textualize/textual/issues/2544
|
||||
- Pasting empty selection in `Input` would raise an exception https://github.com/Textualize/textual/issues/2563
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@@ -332,8 +332,9 @@ class Input(Widget, can_focus=True):
|
||||
event.prevent_default()
|
||||
|
||||
def _on_paste(self, event: events.Paste) -> None:
|
||||
line = event.text.splitlines()[0]
|
||||
self.insert_text_at_cursor(line)
|
||||
if event.text:
|
||||
line = event.text.splitlines()[0]
|
||||
self.insert_text_at_cursor(line)
|
||||
event.stop()
|
||||
|
||||
async def _on_click(self, event: events.Click) -> None:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from textual import events
|
||||
from textual.app import App
|
||||
from textual.widgets import Input
|
||||
|
||||
|
||||
async def test_paste_app():
|
||||
@@ -16,3 +17,28 @@ async def test_paste_app():
|
||||
|
||||
assert len(paste_events) == 1
|
||||
assert paste_events[0].text == "Hello"
|
||||
|
||||
|
||||
async def test_empty_paste():
|
||||
"""Regression test for https://github.com/Textualize/textual/issues/2563."""
|
||||
|
||||
paste_events = []
|
||||
|
||||
class MyInput(Input):
|
||||
def on_paste(self, event):
|
||||
super()._on_paste(event)
|
||||
paste_events.append(event)
|
||||
|
||||
class PasteApp(App):
|
||||
def compose(self):
|
||||
yield MyInput()
|
||||
|
||||
def key_p(self):
|
||||
self.query_one(MyInput).post_message(events.Paste(""))
|
||||
|
||||
app = PasteApp()
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press("p")
|
||||
assert app.query_one(MyInput).value == ""
|
||||
assert len(paste_events) == 1
|
||||
assert paste_events[0].text == ""
|
||||
|
||||
Reference in New Issue
Block a user