-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Cannot match multiple selections during copy/paste if whole line is selected #2697
Comments
I am aware of this problem, but since we can't store extra meta info in the clipboard, I do not know of a sane solution. Do you have a proposal? |
For this particular case, when determining the number of selections on clipboard code could detect when newline is followed by another newline or end-of-text and interpret that the newline is part of selection and not a selection separator. Of course, this only fixes the case where selection ends in a newline, but that is a common case for me, personally, so I think it's worth considering. I guess this assumption is not true if selection contains a multi-line selection with empty lines, but the handling of that case doesn't seem any worse that the way it is now. For example, in recipe above, if you have 4 selections/cursors when pasting, then a match is detected and each part of copied selection is only pasted once. |
(Background: I hesitated to add this feature -- splitting pasted content across cursors -- at all, since it is fundamentally kludgy, due to the code's inability to determine what the user is trying to do.) Adding a special case for this specific situation does not sound like an improvement to me. I don't agree that it is a common case. Why would pasting multi-line ranges where the range is a single line ending in a newline be more common than two lines ending in a newline, or chunks of random size? |
As I said, "multi-line ranges where the range is a single line ending in a newline" is a common case for me, and the handling of the other cases may be a little different, but it's already broken (based on my expectations) so I don't think it's any worse. The only other ways I can think to fix this are:
|
Keeping track of our own copying, so that copy-pastes within CodeMirror (on a single page) at least do the right thing is a good idea. Could you take a look at the attached patch, and tell me if it helps for you? |
Patch works great! I couldn't find any unexpected behavior. Thanks. |
One other change I think would be useful would be to not only match exact number of selections for copy/paste, but also to match exact multiples. For example: Start with multiple selection with 2 selections:
Paste results in:
|
Sublime Text does not seem to do the multiple-of-clipboard thing you describe. Is there a precedent for it? |
No precedent. This would distinguish CodeMirror from Sublime! |
…tiple of clipboard length Issue #2697
I'm only willing to do this for recognized selections that have a known set of ranges (not outside clipboard data), since the potential for false positives becomes a bit too high in the other case. That does cause the problem that people will be surprised when this works from CM itself but not from Sublime Text or another external editor. I'm not sure how often such confusion will come up. I've added the feature for now, but am reserving the right to back it out at a later time. |
Thanks! Fair enough. I predict that CodeMirror will become the precedent that Sublime Text copies! |
This is captured in Brackets issue: adobe/brackets#7923
Recipe:
Result:
Both lines are pasted in each new selection
Expected:
First line is pasted into first selection and second line is pasted in second selection
This seems to be a design flaw since the selection separator is the same as the newline char.
The text was updated successfully, but these errors were encountered: