Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Whole line cut/copy/paste indentation/new line issues #9130

Closed
le717 opened this issue Sep 16, 2014 · 6 comments
Closed

Whole line cut/copy/paste indentation/new line issues #9130

le717 opened this issue Sep 16, 2014 · 6 comments

Comments

@le717
Copy link
Contributor

le717 commented Sep 16, 2014

I'm not totally sure how to explain this, so here is a GIF showing the issue using the Getting Started project. Feel free to rename the issue for clarification.

Running Brackets 0.44 at bf9efc3 from master, also repos in 0.43 or whenever codemirror/codemirror5@12e3efe (codemirror/codemirror5#2382) was pulled in.

whole-line-cut-copy-paste2

@peterflynn
Copy link
Member

@le717 If I understand correctly, what you're seeing is this:

  • Cutting the whole line (with no selection) cuts the whole line, including its indentation and the trailing newline at the end of the line
  • Pasting onto a line that already has indent adds the two levels of indent together (it doesn't merge the indent whitespace, replace the existing whitespace line, normalize indent, etc., or insert a separate line)
  • Pasting with cursor at end of an existing line adds onto that same existing line (it doesn't insert a new line above or below)

This is not a regression from the pre- codemirror/codemirror5#2382 behavior. Cutting a whole line with no selection wasn't even possible before then. And if you cut a whole line manually (e.g. Ctrl+L, then Ctrl+X), you'll see the same exact behavior as I've described above.

Some editors do have fancier behavior than this though:

  • Sublime -- If the line you're pasting onto is all whitespace, the pasted line replaces it instead, so the whitespace isn't added together (and the number of lines doesn't increase). If the line you're pasting onto has non-whitespace chars on it, the pasted line is inserted above it instead. However, this is not true if you manually cut a whole line (or if you cut a whole line from some other app).
  • Webstorm -- If the line you're pasting onto is all whitespace, the pasted line replaces it instead, so the whitespace isn't added together (and the number of lines doesn't increase). This is true even if you manually cut a whole line (or cut it from some other app). But if the line has non-whitespace chars, the behavior is the same as in Brackets.

@le717 is that the sort of behavior you're looking for here?

@le717
Copy link
Contributor Author

le717 commented Sep 16, 2014

@peterflynn Yes, that is what I am seeing. As for the behavior, it is mainly how the whitespace is added to any existing whitespace and the addition of the new line (disregard your third point, I was not meaning to report that, that is fine except for the whitespace addition). Having the whitespace merged so as the indentation is preserved and the trailing new killed would be my expected behavior (inserting a line above is not desired, I already have my cursor where I want the line).

@VinnyFonseca
Copy link

Sublime's behaviour is the correct one for me. It creates a new line, resets the indentation all the way to the left and then pastes the content, instead of pasting line and whitespace at your cursor's position.

+1 for reporting this.

@ficristo
Copy link
Collaborator

@peterflynn is the current behaviour the expected one or should we match Sublime?

@mallman
Copy link

mallman commented Apr 18, 2017

I would like to add my perspective here.

The main issue that's frustrating for me is there doesn't seem to be a way to cut/copy a block of text without codemirror adding an extra newline at the end. This is especially frustrating when I'm trying to paste multiple copies of a single line. I end up having to go back and manually delete an empty line for every paste I performed. Personally, I've never used or seen another editor that behaves this way, so I assumed this is a bug. But maybe this is desirable behavior in some cases?

Cheers.

@mallman
Copy link

mallman commented Apr 18, 2017

The main issue that's frustrating for me is there doesn't seem to be a way to cut/copy a block of text without codemirror adding an extra newline at the end.

Sorry, this seems to be a Safari-only bug: #2900. Guess what browser I'm using? sigh

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

No branches or pull requests

5 participants