-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into selection-fix
- Loading branch information
Showing
10 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""The standard path of selecting text on focus is well covered by snapshot tests.""" | ||
|
||
from textual import events | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import Input | ||
from textual.widgets.input import Selection | ||
|
||
|
||
class InputApp(App[None]): | ||
"""An app with an input widget.""" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Input("Hello, world!") | ||
|
||
|
||
async def test_focus_from_app_focus_does_not_select(): | ||
"""When an Input has focused and the *app* is blurred and then focused (e.g. by pressing | ||
alt+tab or focusing another terminal pane), then the content of the Input should not be | ||
fully selected when `Input.select_on_focus=True`. | ||
""" | ||
async with InputApp().run_test() as pilot: | ||
input_widget = pilot.app.query_one(Input) | ||
input_widget.focus() | ||
input_widget.selection = Selection.cursor(0) | ||
assert input_widget.selection == Selection.cursor(0) | ||
pilot.app.post_message(events.AppBlur()) | ||
await pilot.pause() | ||
pilot.app.post_message(events.AppFocus()) | ||
await pilot.pause() | ||
assert input_widget.selection == Selection.cursor(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters