Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 51924 - Make cut and copy operate on line when selection is empty
Make cut and copy operate on line when selection is empty
Status: VERIFIED FIXED
Product: editor
Classification: Unclassified
Component: Actions/Menu/Toolbar
4.x
All All
: P2 (vote)
: 7.1
Assigned To: UlrichCech
issues@editor
: SIMPLEFIX
: 128072 128073 (view as bug list)
Depends on: 203817
Blocks: 75099
  Show dependency treegraph
 
Reported: 2004-11-30 01:22 UTC by spf
Modified: 2011-10-26 14:27 UTC (History)
5 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Changed the behavior that the position if the cursor is not 'changed' any more and the line does not stay selected (3.35 KB, patch)
2011-10-13 07:25 UTC, UlrichCech
Details | Diff
Corrected the IllegalArgumentException (2.29 KB, patch)
2011-10-18 15:21 UTC, UlrichCech
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description spf 2004-11-30 01:22:37 UTC
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
cut-line.
Comment 1 Roman Strobl 2004-12-07 14:40:05 UTC
Changing subcomponent to clipboard.
Comment 2 Vitezslav Stejskal 2007-11-05 13:30:43 UTC
Moving to the 'other' subcomponent.
Comment 3 Vitezslav Stejskal 2008-02-22 16:15:04 UTC
*** Issue 128072 has been marked as a duplicate of this issue. ***
Comment 4 Vitezslav Stejskal 2008-02-22 16:15:53 UTC
*** Issue 128073 has been marked as a duplicate of this issue. ***
Comment 5 Miloslav Metelka 2008-04-03 18:14:15 UTC
Implemented.
http://hg.netbeans.org/main/rev/e8d47eac9f6b
Comment 6 matthies 2008-08-21 15:17:33 UTC
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)
Comment 7 matthies 2009-08-20 13:35:33 UTC
Updated TM.
Comment 8 rogojine 2009-09-09 10:29:57 UTC
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.
Comment 9 Miloslav Metelka 2009-09-12 18:36:54 UTC
Yes IMHO we could make a configuration option for this possibly on Options->Editor->General tab? Adding Ondra L. to comment on this.
Comment 10 matthies 2009-09-14 13:26:00 UTC
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.
Comment 11 UlrichCech 2011-10-13 07:25:12 UTC
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.
Comment 12 emi 2011-10-13 07:48:15 UTC
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.
Comment 13 UlrichCech 2011-10-13 08:42:59 UTC
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...
Comment 14 emi 2011-10-13 09:15:48 UTC
You are correct, I only tested this with the caret at the beginning of the line...

I think the patch is ready then.
Comment 15 tomwheeler 2011-10-13 13:51:19 UTC
Nice work! 

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.
Comment 16 UlrichCech 2011-10-18 15:21:05 UTC
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 ;-))
Comment 17 emi 2011-10-18 15:36:37 UTC
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.
Comment 18 tomwheeler 2011-10-18 22:39:33 UTC
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.
Comment 19 emi 2011-10-19 06:02:51 UTC
Yes Tom, please commit it to core-main.
Comment 20 tomwheeler 2011-10-19 22:38:47 UTC
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.
Comment 21 Miloslav Metelka 2011-10-20 12:31:52 UTC
I'm sorry for delay. Thank you for the patch it seems to work fine. I have just integrated it into jet-main:

http://hg.netbeans.org/jet-main/rev/b704b928f75e
Comment 22 Quality Engineering 2011-10-24 14:13:12 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/b704b928f75e
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #51924 - Make cut and copy operate on line when selection is empty - patch provided by Ulrich Cech.
Comment 23 Quality Engineering 2011-10-26 14:27:59 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/752313010527
User: Thomas W. Wheeler <tomwheeler@netbeans.org>
Log: Adding Ulrich Cech, who fixed issue #51924 in the First Patch program


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo