-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Copying when nothing is selected no longer affects the clipboard. #3043
Conversation
@@ -492,7 +492,8 @@ def copy(self): | |||
Reimplement Qt method | |||
Copy text to clipboard with correct EOL chars | |||
""" | |||
QApplication.clipboard().setText(self.get_selected_text()) | |||
if len(self.get_selected_text()) > 0: | |||
QApplication.clipboard().setText(self.get_selected_text()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution
In python saying
if len(self.get_selected_text()) > 0
is the same as if len(self.get_selected_text()):
cause if len is 0 then it is the same as saying False.
So we use the second version (as it is common practice in Python)
You can try doing:
bool(0)
bool(1)
bool(100)
bool(-450)
@stephenshank, thanks a lot for your contribution! What you did is exactly what it needed to be done, so well job :-) What @goanpeca meant is that removing I think even |
Thanks to both of you for your feedback! After experimenting with |
Ok, your first contribution to open source is going in ;-) |
Copying when nothing is selected no longer affects the clipboard.
Please notice that this fix is going to be available since Spyder 3.0 beta3, and not in the 2.3.x series (2.3.9 is the next planned release :-) |
Welcome to a whole new world ! 😄 I jusst have a remark about your reasoning. In non critical parts, the correct code isn't usually determined by
|
Great news! Thanks so much! I can see that I clearly have a lot to learn from this community... you can expect to see more pull requests from me in the future. |
Fixes #2835
My first attempt at contributing to open source... constructive criticism welcome!