IDEA has a nice editor feature where Ctrl-x and
Ctrl-c apply to the entire current line when the
selection is empty. This means you don't have to
remember separate keystrokes for copy-line and
Changing subcomponent to clipboard.
Moving to the 'other' subcomponent.
*** Issue 128072 has been marked as a duplicate of this issue. ***
*** Issue 128073 has been marked as a duplicate of this issue. ***
There appears to be a slight quirk with the implementation: When using Ctrl+C to copy the current line, the line
becomes selected at the same time. This is non-intuitive, and the current cursor position is lost. The expected
behavior would be for the cursor position to remain unchanged.
Product Version: NetBeans IDE 6.5 Beta (Build 200808111757)
Java: 1.6.0_04; Java HotSpot(TM) Client VM 10.0-b19
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Could this (cut/copy with no selection operates on whole line) be a configuration option?
I find this feature quite annoying, especially since I'm also using Emacs (C-x C-s to save, oops, I mangled my code and
paste buffer!). As it makes the editor behave differently from what most users are used to, I feel it should be an
option that could be disabled.
Yes IMHO we could make a configuration option for this possibly on Options->Editor->General tab? Adding Ondra L. to comment on this.
It seems to me there are too many issues here at once. There's the original feature request, then there's the bug/quirk
in its implementation that I noted above (and would be happy if it finally would get fixed), and now there's a request
to make the wohle feature an option. IMO it would be better to split this into one or two new issues.
Created attachment 111977 [details]
Changed the behavior that the position if the cursor is not 'changed' any more and the line does not stay selected
Emilian and I decide not to make a configuration option for this little feature.
I changed the behavior so that the cursor position remains untouched and attached the patch file to this issue.
The patch looks good, but I think for 'cut' there is no need to re-set the caret since it already has a good position after target.cut().
Only 'copy' needs the caret position to be changed, especially since we want to get rid of the artificial selection.
Thanks for the review.
But if I don't "handle the caret position in cut", the caret jumps to the starting point of the line, so if you are in the middle of the line and press <Strg>+<x>, the line is cut of, but the caret jumps to the beginning of the line...
You are correct, I only tested this with the caret at the beginning of the line...
I think the patch is ready then.
I have e-mailed the two NetBeans engineers (Jan Lahoda and Miloslav Metelka) who normally work on this module and asked them to integrate it into NetBeans hg repository. I'm not sure what their schedules are like, so if it's not integrated within a few days, I will apply the patch and push it to core-main.
Created attachment 112184 [details]
Corrected the IllegalArgumentException
The cut-action now behaves like in IntelliJ, that the cursor jumps to the first
position of the line following the line cutted off (no more
BadLocationExceptions possible ;-))
I support this patch :-)
Ulrich made a more complex one using modelToView but I don't think we need such a thorough cursor management.
The current patch fixes the selection that remained after copy. Now Ctrl-C / Ctrl-X work as expected.
So is this patch ready to be integrated into NetBeans (assuming it passes all the tests)? If so, let me know and I will integrate it and push it to core-main, unless Miloslav beats me to it.
Yes Tom, please commit it to core-main.
I had some trouble applying the patch. The "hg import" command rejected it. I am getting ready to meet someone, so I will look into why that is and try again tomorrow.
I'm sorry for delay. Thank you for the patch it seems to work fine. I have just integrated it into jet-main:
Integrated into 'main-golden'
User: Miloslav Metelka <firstname.lastname@example.org>
Log: #51924 - Make cut and copy operate on line when selection is empty - patch provided by Ulrich Cech.
Integrated into 'main-golden'
User: Thomas W. Wheeler <email@example.com>
Log: Adding Ulrich Cech, who fixed issue #51924 in the First Patch program