Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Undesirable feature: multiline brace completion
szczepan:
The editor should not auto-expand auto-completed braces into a multiline block like this:
--- Code: ---{
|
}
--- End code ---
There are many situations in coding where single line blocks are needed - simple one-liner accessors, array-of-structs initializers etc. Just imagine having to undo the brace completion's auto-formatting for each line of this:
SKeyMap kmap[]= {
{ EKA_MOVE_FORWARD, KEY_UP },
{ EKA_MOVE_BACKWARD, KEY_DOWN },
{ EKA_STRAFE_LEFT, KEY_LEFT },
{ EKA_STRAFE_RIGHT, KEY_RIGHT } /* , */
// ... in a real app, dozens more keymappings would follow...
};
There is a simple and widely implemented solution that performs satisfactorily both for one-line and multiline blocks:
* on '{' typed, only complete with '}' behind the caret, don't format
* on CR typed while the caret is between adjacent '{' and '}' (possibly allowing single line whitespace), do the nice formatting.
Type '{'. Want the block in a single line? Just continue typing. Want indented multiline block? Press Enter. That's how MonoDevelop does it, and it rocks.
An alternative would be to register the whole sequence comprising the multiline formatting (but not completing the brace) as a single Undo step. Type '{'. Want indented multiline block? Just continue typing. Want the block in a single line? Press Ctrl+Z.
_
Kazade:
Just wanted to add my +1 to this. The new brace completion is really irritating. I like the behaviour that Netbeans has (this might be the same as you explained, I'm not sure.
If I type this:
--- Code: ---void Something::SomeMethod(|
--- End code ---
The closing bracket should appear after the caret. But, if I then type a closing bracket, the closing brackets shouldn't double up, but instead my closing bracket should overwrite the auto-completed one.
If I then type a brace:
--- Code: ---void Something::SomeMethod() {|
--- End code ---
Nothing happens until I press enter THEN it does this:
--- Code: ---void Something::SomeMethod() {
|
}
--- End code ---
This is obviously my coding style, but if you prefer your braces lined up the same thing should happen. The second brace should only appear when Enter is pressed. Leaving the caret indented.
Kalith:
I think this is a very interesting feature, but I also think it should be heavily customizable for multiple reasons. Different coding styles, different habits...
For example, I'm actually not bothered by this brace autocompletion system, but the new line alignment (from the latest nightly) just doesn't fit my coding habits. If I want to type this :
--- Code: ---mMovement = Vector(
0.0f, 0.0f, 0.0f
);
--- End code ---
... I write the first line, press enter :
--- Code: ---mMovement = Vector(
|)
--- End code ---
... and I have to remove all the spaces.
I'm also not pleased by the way bracket completion works. If the caret is placed before a ')' and you try to write another, it always "replaces" the one that is already here. This is annoying in this kind of situation :
--- Code: ---someFunction(someOtherFunction(|));
--- End code ---
If you accidentally press [Del.] (happens to me all the time, really...) and want to type the ')' back, you either have to type it twice, or move the caret after the last ')' then type it once (it's a two key process anyway, and it gets even worse when there are many brackets).
Same goes for quotation marks :
--- Code: ---someFunction("|");
--- End code ---
Press [Del.] or [Backspace] then type a quotation mark, you'll end up with this :
--- Code: ---somefunction(""|");
--- End code ---
I don't know what could be done to solve this, maybe track for unclosed brackets / q. marks ?
Anyway thanks for the work you're putting on this, C::B really is my favorite IDE :)
oBFusCATed:
--- Quote from: Kalith on October 13, 2009, 07:19:58 pm ---...
For example, I'm actually not bothered by this brace autocompletion system, but the new line alignment (from the latest nightly) just doesn't fit my coding habits. If I want to type this :
--- Code: ---mMovement = Vector(
0.0f, 0.0f, 0.0f
);
--- End code ---
...
--- End quote ---
This comes from the brace indentation patch I've submitted. And if you really want it, I can make a patch that allows the user to disable it.
The idea of the patch is to allow you to write:
--- Code: --- my_func(param1, param2, param3,
param4, param5, param6);
--- End code ---
Best regards.
Kalith:
I understand the need, and actually find it useful in some situations, but in my case it's doing more harm than good.
Anyway, I'd be very happy if this was to become configurable !
Thanks for your time.
Navigation
[0] Message Index
[#] Next page
Go to full version