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

Feature request: Cut/copy line when selection is a cursor #2382

Closed
njx opened this issue Mar 17, 2014 · 7 comments
Closed

Feature request: Cut/copy line when selection is a cursor #2382

njx opened this issue Mar 17, 2014 · 7 comments

Comments

@njx
Copy link
Contributor

njx commented Mar 17, 2014

In many editors, when the selection is a cursor (or multiple cursors), copy and cut operate on the line(s) containing the cursor(s). This is a very handy feature for quickly moving code around, and we get this request a lot in Brackets.

Is this possible to implement in CodeMirror? I don't fully understand how CM manages the clipboard operations (since I know you can't directly mess with the clipboard from JS), but my understanding is that it's managed via the hidden input field. Would it be possible to make it so that when the selection is a cursor/cursors, the hidden input field contains the lines containing the cursors and selects them? Or would that mess up other logic that relies on the input field?

@njx
Copy link
Contributor Author

njx commented Mar 17, 2014

(BTW, this isn't a request for v4 specifically - I know you're trying to close that down :))

@marijnh
Copy link
Member

marijnh commented Mar 17, 2014

This could probably be hacked into the prepareCopy function rather easily. I'll leave this open and look at it later.

@marijnh
Copy link
Member

marijnh commented Mar 21, 2014

Try with attached patch.

@wnr
Copy link

wnr commented Mar 24, 2014

Thanks for implementing this :)

I have tried it out in brackets now and I have the following feedback:

  • ctrl-x results in a highlight flash while ctrl-c doesnt.
  • ctrl-x with mix of word / line cursors breaks the cutting (only the words get cut).
  • Same as above goes for ctrl-c.

Thanks

@njx
Copy link
Contributor Author

njx commented Mar 24, 2014

FWIW, looks like all those issues repro in the CodeMirror demo, so it's not due to Brackets-specific issues.

@marijnh
Copy link
Member

marijnh commented Mar 25, 2014

Do any of these constitute actual problems, though? It seems sane to me that if you have a selection, cut/copy acts on that selection. And the flash of selection when cutting is something I am aware of, but which didn't seem like an issue (it mirrors the act of actually selecting and cutting the lines).

@wnr
Copy link

wnr commented Mar 26, 2014

Well, I do think it's confusing that only the selections get cut. Sublime and IntelliJ do cut all cursors (selections and non-selections). However, I do think it's sane to just copy the selections on copy. Similarly, I think only the selections should get copied on cut (the same way sublime behaves), but still all lines/selections should get removed.

I can agree that the selection flash is okay, but I feel it should behave the same with copy also then. However, this is not really an issue to me.

So I guess the real issue is that the lines with no selections do not get removed (does not need to be copied) on cut. If that gets fixed I believe CM would work in the same way as the other editors (except for the flashing highlight, which is okay). :)

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

3 participants