[MonoDevelop] New code formatter joins line to aggressively

Michael Hutchinson m.j.hutchinson at gmail.com
Fri Sep 11 13:35:45 EDT 2009


On Fri, Sep 11, 2009 at 7:30 AM, Oskar Berggren
<oskar.berggren at gmail.com> wrote:
> I was very happy to learn that MD 2.2 will include a code formatter.
> This is a feature I've really missed from visual studio.
>
> I've done some experimenting with it, and have a number of opinions:
>
> * Apart from "Format document", there should also be a "Format
> selection". The latter one would operate on the current line only, if
> there is no selection.
>
> * It joins lines way to aggressively.
>
> For example, this manually formatted code (best viewed in monospace...):
>
>    ICriteria criteria =
>        session.CreateCriteria(typeof(RegisterRequest))
>            .CreateCriteria("Connection")
>            .Add( Restrictions.Eq("Name", connectionName) );
>
> becomes this unreadable thing:
>
>    ICriteria criteria = session.CreateCriteria
> (typeof(RegisterRequest)).CreateCriteria ("Connection").Add
> (Restrictions.Eq ("Name", connectionName));

Yes, this is definitely a problem. Could you file a bug?

http://monodevelop.com/Developers#Reporting_Bugs

> Maybe it shouldn't join lines at all. Rather, if a statement is
> manually divided over several lines, it should probably remain on as
> many lines with all lines except the first indented one more step than
> the first line. Possibly, if it is inside parentheses then perhaps the
> subsequent lines should align with the parentheses, like they did in
> the MD 2.0's indentation mode:
>
>    var recent_not_infinite_enddate =
>        Restrictions.And(Restrictions.Ge("EndDate", earliestChangeTime),
>                         Restrictions.Lt("EndDate", DateTime.MaxValue));
>
>
> Now.... another question is: Should it wrap lines that are too long?

I think so. We'd need to think up some options for the various
wrapping styles, and have options for various thresholds that would
cause it to start wrapping things.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Monodevelop-list mailing list