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

Ctrl-C when nothing selected clears clipboard #6281

Closed
vincenzon opened this issue Apr 29, 2019 · 11 comments
Closed

Ctrl-C when nothing selected clears clipboard #6281

vincenzon opened this issue Apr 29, 2019 · 11 comments
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@vincenzon
Copy link

Describe the bug
In a notebook cell, hitting Ctrl-C when nothing is selected clears the clipboard.

To Reproduce

  1. Select some text in a notebook cell.
  2. Hit Ctrl-C to copy that text to the clipboard.
  3. Hit Ctrl-V to paste that text to a cell.
  4. With no text selected, hit Ctrl-C again.
  5. Hit Ctrl-V, nothing is pasted because the Ctrl-C in step 4 cleared the clipboard.

Expected behavior
The clip board does not get cleared when Ctrl-C is pressed and no text is selected.

Desktop (please complete the following information):

  • OS: Windows 10
  • Chrome
  • JupyterLab
@jasongrout jasongrout added this to the Reference milestone Apr 30, 2019
@jasongrout
Copy link
Contributor

In some experiments, it looks like if I copy with nothing selected, it copies the entire line. This is how it seems to work in upstream Codemirror as well (you can try it at https://codemirror.net/).

When you did your second Ctrl-C, were you on a blank line? If so, it seems it was copying the blank line (i.e., it copies the line you were on). If you are on a line with some text, does it copy the entire line?

@vincenzon
Copy link
Author

Yeah, that seems to be what is happening. Nevertheless, from the UX perspective, at least this U, that still is "clearing the clipboard" since I hit this problem when I unintentionally hit Ctrl-C when my intent is to hit Ctrl-V. It would be nice if this could be configurable.

@jasongrout
Copy link
Contributor

I see your point. It appears this is an upstream Codemirror issue. I just searched there, are here are some relevant issues:

codemirror/codemirror5#2824
codemirror/codemirror5#2382

I haven't read through the discussions there in detail. If you'd like to pursue this, would you read through those discussions and tell us what you think?

@vincenzon
Copy link
Author

My read of those issues and their associated ones is that there are some people that consider this a feature, and some that consider this a bug. I guess that suggests it should be configurable? It looks like the resolution in: adobe/brackets#9311 was to do that.

@jasongrout
Copy link
Contributor

Thanks for the high-level summary. It looks like adobe/brackets#11706 is where that was implemented in brackets.

From that issue, we see that there is a codemirror preference to turn on and off the copy-line-when-no-selection behavior. We could expose that preference in our settings, just like the other codemirror preferences we are exposing.

Our facility for changing codemirror preferences is in https://github.com/jupyterlab/jupyterlab/blob/master/packages/codemirror-extension/schema/commands.json and https://github.com/jupyterlab/jupyterlab/blob/master/packages/codemirror-extension/src/index.ts for text editor preferences.

For notebooks, the preferences for the cell editors are exposed at https://github.com/jupyterlab/jupyterlab/blob/master/packages/notebook-extension/schema/tracker.json#L267-L331, and the generic options for an editor used in the notebook are at https://github.com/jupyterlab/jupyterlab/blob/master/packages/codeeditor/src/editor.ts#L579-L668

Changing to good first issue. I think what would be needed is picking one of the existing codemirror options that we expose, and doing something similar for this option.

@jasongrout
Copy link
Contributor

For reference, Sublime apparently has the copy_with_empty_selection option, defaulting to copy the current line: http://docs.sublimetext.info/en/latest/reference/settings.html

@jasongrout
Copy link
Contributor

jasongrout commented May 1, 2019

Also for reference, it seems that Visual Studio Code has this setting: "editor.emptySelectionClipboard": true (default to true), which apparently has the behavior, when there is no selection and you do the copy shortcut, to copy the line if and only if the line is not just whitespace.

@peterdietz
Copy link

On Mac OSX and Chrome, Command-C, on a blank line, did not clear the buffer, and my previously copied line from Command-V was still in the buffer. So there could be some OS specific behavior here.

@ggbhat
Copy link
Contributor

ggbhat commented Feb 2, 2020

Thanks for the high-level summary. It looks like adobe/brackets#11706 is where that was implemented in brackets.

From that issue, we see that there is a codemirror preference to turn on and off the copy-line-when-no-selection behavior. We could expose that preference in our settings, just like the other codemirror preferences we are exposing.

Our facility for changing codemirror preferences is in https://github.com/jupyterlab/jupyterlab/blob/master/packages/codemirror-extension/schema/commands.json and https://github.com/jupyterlab/jupyterlab/blob/master/packages/codemirror-extension/src/index.ts for text editor preferences.

For notebooks, the preferences for the cell editors are exposed at https://github.com/jupyterlab/jupyterlab/blob/master/packages/notebook-extension/schema/tracker.json#L267-L331, and the generic options for an editor used in the notebook are at https://github.com/jupyterlab/jupyterlab/blob/master/packages/codeeditor/src/editor.ts#L579-L668

Changing to good first issue. I think what would be needed is picking one of the existing codemirror options that we expose, and doing something similar for this option.

Raised PR by making above changes mentioned.

@ggbhat
Copy link
Contributor

ggbhat commented Feb 7, 2020

PR Merged..

@telamonian
Copy link
Member

fixed by #7842

@vincenzon and for anyone else who has the same issue, you can fix it by going to the "Notebook" section of the advanced settings editor and then setting the lineWiseCopyCut option to false

@telamonian telamonian modified the milestones: Future, 2.0 Feb 7, 2020
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Mar 10, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

5 participants