Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting in Input with an empty string crashes the program #2563

Closed
1j01 opened this issue May 14, 2023 · 3 comments · Fixed by #2568
Closed

Pasting in Input with an empty string crashes the program #2563

1j01 opened this issue May 14, 2023 · 3 comments · Fixed by #2568
Assignees

Comments

@1j01
Copy link
Contributor

1j01 commented May 14, 2023

Pressing middle mouse button to paste causes this error in Input._on_paste if the clipboard is empty of text:

╭───────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────╮
│ /home/io/Projects/textual-paint/.venv/lib/python3.10/site-packages/textual/widgets/_input.py:335 in _on_paste                                                                       │
│                                                                                                                                                                                     │
│   332 │   │   │   event.prevent_default()                                                                                                                                           │
│   333 │                                                                                                                                                                             │
│   334 │   def _on_paste(self, event: events.Paste) -> None:                                                                                                                         │
│ ❱ 335 │   │   line = event.text.splitlines()[0]                                                                                                                                     │
│   336 │   │   self.insert_text_at_cursor(line)                                                                                                                                      │
│   337 │   │   event.stop()                                                                                                                                                          │
│   338                                                                                                                                                                               │
│                                                                                                                                                                                     │
│ ╭──────────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────────╮                                                  │
│ │ event = Paste(text='')                                                                                                         │                                                  │
│ │  self = CharInput(id='selected_color_char_input', classes={'color_well'}, pseudo_classes={'focus', 'focus-within', 'enabled'}) │                                                  │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range

To reproduce, use printf "" | xsel before pasting with MMB.

Textual Diagnostics

Versions

Name Value
Textual 0.22.3
Rich 13.3.5

Python

Name Value
Version 3.10.6
Implementation CPython
Compiler GCC 11.3.0
Executable /home/io/Projects/textual-paint/.venv/bin/python

Operating System

Name Value
System Linux
Release 5.19.0-41-generic
Version #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2

Terminal

Name Value
Terminal Application vscode (1.77.3)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=183, height=32
legacy_windows False
min_width 1
max_width 183
is_terminal True
encoding utf-8
max_height 32
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@github-actions
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@rodrigogiraoserrao
Copy link
Contributor

Hey there @1j01, I confirm I can reproduce this issue and we're working on a fix for it.

rodrigogiraoserrao added a commit that referenced this issue May 15, 2023
Related issues: #2563.
rodrigogiraoserrao added a commit that referenced this issue May 15, 2023
Related issues: #2563.
@rodrigogiraoserrao rodrigogiraoserrao self-assigned this May 15, 2023
@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants