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

Copying when nothing is selected no longer affects the clipboard. #3043

Merged
merged 2 commits into from
Mar 9, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spyderlib/widgets/sourcecode/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Member

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)


def toPlainText(self):
"""
Expand Down