This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 101133 - Improve Ctrl-semicolon action
Summary: Improve Ctrl-semicolon action
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-16 12:27 UTC by _ tboudreau
Modified: 2013-09-02 14:19 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Patch to java/editor to add the necessary actions (8.52 KB, patch)
2007-09-22 10:24 UTC, _ tboudreau
Details | Diff
Corrected patch; previous patch also contained some additional useful abbreviations not related to this issue (7.18 KB, patch)
2007-09-22 12:16 UTC, _ tboudreau
Details | Diff
Mac keybindings patch (879 bytes, patch)
2007-09-25 01:05 UTC, _ tboudreau
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2007-04-16 12:27:27 UTC
Very often you will use code completion to create a method call.  The caret is
placed inside the ()'s.  You enter something.  To finish the line, you have to
lift your hand from the keyboard, arrow to the end of the line or press End,
then enter a semicolon and (usually) press enter.

I have a small module in contrib that implements actions for
 - Ctrl semicolon - insert a ; at the end of the line (but don't move the caret)
 - Ctrl shift semicolon - do the same thing + enter and position the caret on
the newly created line

I find it makes a huge difference in speed in the editor.  It's a simple
solution to a simple problem.  Any reason not to do this in the Java editor?
Comment 1 lmineiro 2007-09-18 12:13:54 UTC
For other non-US keyboards you usually have to use Shift to get a semicolon. So that would be a three key press to
insert the ; at the end of the line not moving the caret and being unable to do the same moving the caret to the new
line since you would be pressing Shift already for the first action.

I agree on the concept, I find myself exactly in the same keypress overhead and ideally we should have some nice
shortcuts as described.

On my keyboard (and every portuguese keyboard), I have the "," and ";" in the same key, and you have to Shift to get the
";".

I believe more international keyboards behave the same way, can't be sure.
Comment 2 _ tboudreau 2007-09-18 17:10:59 UTC
Suggestions for appropriate shortcuts are welcome - this might be a thing that should be handled differently in the case of international keyboards;  at any 
rate, it sounds like shift should not be used to indicate inserting a newline.  Maybe ctrl-semicolon and alt-semicolon.

Really would be nice to detect, e.g. and if statement and insert a { if that's the appropriate line ending, but that's probably too much intelligence for this 
round.
Comment 3 _ tboudreau 2007-09-22 10:24:16 UTC
Created attachment 49285 [details]
Patch to java/editor to add the necessary actions
Comment 4 _ tboudreau 2007-09-22 10:28:39 UTC
I've attached a patch that implements these actions in java/editor.

Currently it binds ctrl-semicolon to append a semicolon to the end of the line, and ctrl-shift-semicolon to append, insert a properly indented newline and 
move the caret there.

Re the issue that on some international keyboards, ; is created with the shift key already:  Probably the right solution would be to find some additional binding 
that is friendly to this case.  Ctrl-comma seems easy and would make sense.  It is currently bound to bring up the options dialog opened to the editor tab.  It 
seems a waste of a two-key shortcut to bind that to something so rarely used - I'd prefer if we found a different binding for that and also bound the append-
only action to that keystroke, for users who cannot type a semicolon without pressing shift.
Comment 5 _ tboudreau 2007-09-22 12:16:32 UTC
Created attachment 49288 [details]
Corrected patch;  previous patch also contained some additional useful abbreviations not related to this issue
Comment 6 Petr Hrebejk 2007-09-24 11:41:00 UTC
Seems to be OK. I applied the patch with exception for the Mac keybindings it should work even if in Default only. Tim
please verify and eventually add it into mac keybindings when it does not work on mac.

I think it could be improved later for finishing any kind of statement
1) Add braces correctly
2) If special case do something smart e.g.

if ( cond | 

would do:

if ( cond ( {
}


switch( enum | 

would do:

switch( enum ) {
case e1:
    break;
case en:
    break;
default:
}

etc.

Thus leaving open and changing the summary

Checking in editor/java/JavaKit.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/JavaKit.java,v  <--  JavaKit.java
new revision: 1.48; previous revision: 1.47
done
Checking in editor/java/BracketCompletion.java;
/cvs/java/editor/src/org/netbeans/modules/editor/java/BracketCompletion.java,v  <--  BracketCompletion.java
new revision: 1.18; previous revision: 1.17
done
RCS file: /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/InsertSemicolonAction.java,v
done
Checking in java/editor/codegen/InsertSemicolonAction.java;
/cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/InsertSemicolonAction.java,v  <--  InsertSemicolonAction.java
initial revision: 1.1
done
Checking in java/editor/resources/DefaultKeyBindings.xml;
/cvs/java/editor/src/org/netbeans/modules/java/editor/resources/DefaultKeyBindings.xml,v  <--  DefaultKeyBindings.xml
new revision: 1.18; previous revision: 1.17
done
Comment 7 _ tboudreau 2007-09-25 01:03:54 UTC
Ugh, I did have changes to the mac keybindings, but somehow they didn't end up in the patch.  Will attach.

Agree, this should be the way to do appropriate completion of any line, but I didn't want to be too ambitious for something we will try to get into 6.0.  Also it 
could be enhanced not to add a ; to a line if one is already there.

Thanks for getting this in!
Comment 8 _ tboudreau 2007-09-25 01:05:39 UTC
Created attachment 49403 [details]
Mac keybindings patch
Comment 9 _ tboudreau 2007-09-25 01:11:35 UTC
Never mind the patch, I committed it.