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 a whole blank line clears previously copied content #2824

Closed
le717 opened this issue Sep 26, 2014 · 15 comments
Closed

Copying a whole blank line clears previously copied content #2824

le717 opened this issue Sep 26, 2014 · 15 comments

Comments

@le717
Copy link
Contributor

le717 commented Sep 26, 2014

Originally reported at adobe/brackets#9311.


Steps to reproduce:

  • Type then select some text and copy it
  • Paste it on a new line, note how the content is pasted
  • Use the whole line copy feature to copy a blank line
  • Paste, a blank line is pasted
  • Expected: the blank line is not copied, and instead our previous content is pasted instead

I've traced this to f4ae5b4 (#2697). It appears the d.input.value = lastCopied.join("\n"); and d.input.value = text.join("\n"); lines are the culprits, but I am not totally sure on that. Disabling them also remedies some issues I found in adobe/brackets#9130.

I am not sure what CodeMirror demo I can use to reproduce this in, but the expected behavior can be seen in Brackets 0.38, and the bug in Brackets 0.42+.

@mfarooqi
Copy link

@le717 Thanks for proceeding it further.

@marijnh
Copy link
Member

marijnh commented Sep 29, 2014

You never explicitly described the behavior you expect. Should the per-line copy and cut be disabled when the cursor is on a blank line? What if it contains only whitespace?

@mfarooqi
Copy link

Its simple..until something is not selected or line is empty, copy function shouldn't be functional.. rather only paste should work.. there C and V are so close on keyboard. an unexpected COPY instead of PASTE clears the clipboard.

@le717
Copy link
Contributor Author

le717 commented Oct 2, 2014

@marijnh The expected behavior is the per-line copy and cut should not act on a blank line. If there is whitespace, then it should act. The code is already working that way except for the two aforementioned lines, d.input.value = lastCopied.join("\n"); and d.input.value = text.join("\n"); which break it by appending a new line to the "selected text" (nothing), thereby creating this bug

@mfarooqi
Copy link

mfarooqi commented Oct 2, 2014

by the way... brackets are puerly for coders.. and in coding by default
syntax does have spaces on every next lines...

Regards

Muhammad Farooqi
m.farooqi@skype 92 345 5244 143

On Thu, Oct 2, 2014 at 11:39 PM, Triangle717 notifications@github.com
wrote:

@marijnh https://github.com/marijnh The expected behavior is the
per-line copy and cut should not act on a blank line. If there is
whitespace, then it should act. The code is already working that way except
for the two aforementioned lines, d.input.value = lastCopied.join("\n");
and d.input.value = text.join("\n"); which break it by appending a new
line to the "selected text" (nothing), thereby creating this bug


Reply to this email directly or view it on GitHub
#2824 (comment)
.

@marijnh
Copy link
Member

marijnh commented Oct 3, 2014

I'm still doubtful about whether this should be changed at all. Calling it a bug is definitely nonsense. Sublime Text behaves the same way, by design.

@mfarooqi
Copy link

mfarooqi commented Oct 3, 2014

are you a follower of Sublime?.. I'm sure not.. but what all other great
systems do. I used first sublime.. but just because of this issue I quit
using sublime... and moved to adobe Code CC.. That was a great app. in fact
that is.. But some extensions were not supported by Adobe Code CC.. .And a
guy in Adobe told me to go with Brackets.. This Code CC is a same build but
Brackets is updated.. And when I started Brackets.. I had this issue.. I
don't know whether it's a bug or not.. but it is not in Adobe Code CC..

I'm currently working on an html5 ONE page application with 4000+ line of
code.. If i need to copy a function... I select that.. Copy it... and on
any next lines.. paste it.. and accidently press Option+C instead of
Option+V .. all selection gone.. I then again need to search.. what I had
copied..

It's not a bug.. then it's not a feature too...

Regards

Muhammad Farooqi
m.farooqi@skype 92 345 5244 143

@marijnh
Copy link
Member

marijnh commented Oct 3, 2014

I'm interested in what the Brackets devs consider the preferred behavior here. @peterflynn @redmunds Care to chime in?

@marcelgerber
Copy link
Contributor

I'm not a Brackets dev, but I wonder when you ever actually wanted to copy a blank line.
Imho, you shouldn't even be able to copy all-whitespace lines.

@redmunds
Copy link
Contributor

redmunds commented Oct 3, 2014

@marijnh I honestly don't use the "copy line cursor is in" feature -- I was only aware of it because I accidentally did it one time :)

Seems useful to be able to copy entire line if cursor is at beginning of line. Seems weird (to me) to copy line when cursor is at end (or middle) of line because you have to move cursor to beginning of line when pasting a whole line, anyway.

Copying an empty line seems like it would never be the intention, so I think that should not be done (i.e. don't clear clipboard). Copying an all whitespace line could be the intent and useful, so that should be allowed.

cc @peterflynn @njx

@peterflynn
Copy link
Contributor

@marijnh This was behavior we originally requested, in #2382. Until now I've never heard any objections/confusion related to this. As others have noted, a number of other popular editors work the same way out of the box -- including Sublime, Visual Studio, and the WebStorm/IntelliJ family. Personally, I use this feature every day so I definitely wouldn't want to see it go away.

I wonder if the simplest solution is to just add a CM option for this (which we could expose as a Brackets preference)...

The suggestion to disable copying blank or all-whitespace lines is interesting, but I'm not sure it's the best solution:

  1. In @mfarooqi's example of hitting Copy by accident when he meant to hit Paste, it's equally likely the cursor was on a line with text on it -- so this wouldn't fix that case. (Though it's an open question how much an editor should be designed around user error).
  2. Copying a non-blank, but all-whitespace line can still be useful, e.g. while reformatting whitespace.
  3. It might be confusing if copy without a selection appeared to work only sometimes -- how long would it take to figure out the pattern? (especially if it distinguishes between blank and blank with whitespace).

I've flagged the original Brackets bug for review with the larger team, so we should be able to get back to you with a more firm opinion soon.

@peterflynn
Copy link
Contributor

Btw, to @redmunds's point about paste: that part I would call a bug. It was reported as a bug in Brackets already, since that's not how other editors with this feature work: adobe/brackets#9130 (comment). When line cut/copy/paste is available regardless of cursor position, it makes moving code around really smooth and fast.

@marijnh
Copy link
Member

marijnh commented Oct 6, 2014

@peterflynn Could you define more clearly what behavior you'd want to see? When does the clipboard content count as line-based? Should this property influence anything else?

@mfarooqi
Copy link

check out this please ... adobe/brackets#9311

@marijnh
Copy link
Member

marijnh commented Feb 24, 2015

Closing this. @peterflynn If you can tell me more about the way 'pasting over' blank lines should work, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants