-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Prevent copying an empty line by accident #59193
Conversation
@@ -142,6 +142,13 @@ class ExecCommandCopyAction extends ExecCommandAction { | |||
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) { | |||
return; | |||
} | |||
// prevent copying an empty string by accident | |||
if (editor.getSelections().length === 1 && editor.getSelection().isEmpty()) { |
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.
You may want to compare between editor.getModel().getLineFirstNonWhitespaceColumn
and editor.getModel().getLineMaxColumn
instead of doing a substring.
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.
The approach looks good to me. The only comment I have is doing less costly comparison.
cc @rebornix |
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.
It looks good to me.
Is this setting configurable? I preferred the old behavior, copy whatever line I press 'Ctrl +c' on regardless of its content. This PR assumes a user didn't want to copy a blank line which I usually do. It seems the real fix is to copy whatever line the user used the keyboard shortcut on and recommend clipboard managers if you copy something that you didn't intend. |
FYI, I opened #69903 for this. Ctrl + C (or similar keyboard mappings on other editors like notepad++ or even online editors - like firebase rules editor) make no assumption on intention. Ctrl + C just copies the line. I'm not opposed to inference, but in this case, it seems like it should be configurable and not assumed that copy of a blank line was in error. 😄 |
I do not think this is a mistake, on the contrary I think he can improve my efficiency, please return to the original. |
Fixes #55243