mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
skip copy in input/textarea if there is nothing to copy
This commit is contained in:
@@ -11,6 +11,7 @@ from rich.text import Text
|
||||
from typing_extensions import Literal
|
||||
|
||||
from textual import events
|
||||
from textual.actions import SkipAction
|
||||
from textual.expand_tabs import expand_tabs_inline
|
||||
from textual.screen import Screen
|
||||
from textual.scroll_view import ScrollView
|
||||
@@ -1106,7 +1107,11 @@ class Input(ScrollView):
|
||||
|
||||
def action_copy(self) -> None:
|
||||
"""Copy the current selection to the clipboard."""
|
||||
self.app.copy_to_clipboard(self.selected_text)
|
||||
selected_text = self.selected_text
|
||||
if selected_text:
|
||||
self.app.copy_to_clipboard(selected_text)
|
||||
else:
|
||||
raise SkipAction()
|
||||
|
||||
def action_paste(self) -> None:
|
||||
"""Paste from the local clipboard."""
|
||||
|
||||
@@ -16,6 +16,7 @@ from typing_extensions import Literal
|
||||
|
||||
from textual._text_area_theme import TextAreaTheme
|
||||
from textual._tree_sitter import TREE_SITTER, get_language
|
||||
from textual.actions import SkipAction
|
||||
from textual.cache import LRUCache
|
||||
from textual.color import Color
|
||||
from textual.content import Content
|
||||
@@ -2513,6 +2514,8 @@ TextArea {
|
||||
selected_text = self.selected_text
|
||||
if selected_text:
|
||||
self.app.copy_to_clipboard(selected_text)
|
||||
else:
|
||||
raise SkipAction()
|
||||
|
||||
def action_paste(self) -> None:
|
||||
"""Paste from local clipboard."""
|
||||
|
||||
Reference in New Issue
Block a user